#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > sortme;
int n,a,rs;
int main()
{
	cin>>n;
	for(int i=0; i<n; ++i)
	{
		cin>>a;
		sortme.push_back({a, i});
	}
	sort(sortme.begin(), sortme.end());
	for(int i=0; i<n; ++i)
	{
		rs+=(i%2 != sortme[i].second%2);
	}
	rs/=2;
	cout<<rs;
}
