#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

const int MAXN = 1e5 + 5;
int n, ans;
int Arr[MAXN];
int back[MAXN];
map <int, int> Map;

int main() { 
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &Arr[i]);
		back[i] = Arr[i];
	}
	sort(Arr, Arr + n);
	for (int i = 0; i < n; i++)
		Map[Arr[i]] = i;
	for (int i = 0; i < n; i++)
		if (Map[back[i]] % 2 != i % 2)
			ans++;
	printf("%d\n", ans / 2);
	return 0;
}