#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

int N;
pair<ll, int> A[100000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)cin >> A[i].first, A[i].second = i;
	sort(A, A + N);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if ((i - A[i].second + 114514364) % 2 == 1)ans++;
	}
	cout << ans / 2 << endl;
	return 0;
}