#include <bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
vector<pii> A;
int n,x;
int main(){
	cin >> n;
	for(int i = 0; i < n;i++){
		cin >> x;
		A.push_back(pii(x,i));
	}
	sort(A.begin(),A.end());
	int c = 0;
	for(int i = 0; i < n;i+=2){
		if((A[i].second + i)%2)
			c++;
	}
	cout << c << endl;
}