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