#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int, int>P;
P a[114514];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int b;
		cin >> b;
		a[i] = P(b, i);
	}
	int ans = 0;
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		if (a[i].second % 2 != i % 2)ans++;
	}
	cout << ans/2 << endl;
}