#include <iostream>

using namespace std;
const int N = 1e6 + 10;
typedef pair <int, int> pii;

int n;
pii a[N];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}

	int ans = 0;
	sort (a, a + n);
	for (int i = 0; i < n; i += 2)
		if ((i % 2) != (a[i].second % 2))
			ans ++;

	cout << ans << endl;
}