#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, A[100000], count = 0;
	map<int, int> mp;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		mp[A[i]] = i;
	}
	sort(A, A + N);
	for (int i = 0; i < N; i++) {
		count += abs(mp[A[i]] - i) % 2;
	}
	cout << count / 2;
}