#include <bits/stdc++.h>
using namespace std;
int n, ans;
struct node {
	int val, st;
}a[100005];
bool cmp(node t, node b) {
	return t.val < b.val;
}
int main() {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &a[i].val);
		a[i].st = i;
	}
	sort (a + 1, a + n + 1, cmp);
	for (int i = 1; i <= n; i++) {
		if ((a[i].st - i) % 2)
			ans++;
	}
	printf ("%d", ans/2);
	return 0;
}