#include <bits/stdc++.h>
#include <ext/algorithm>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

/**************************************************************/

	int N;
	cin >> N;
	pair<int,int> array[N];

	int count;
	for(int i = 0; i < N; i++)
	{
		cin >> count;
		array[i] = {count,i};
	}

	sort(array, array+N);
	count = 0;
	for(int i = 0; i < N; i++)
		if(i%2 != array[i].second%2)
			count++;

	cout << count/2 << endl;
}