#include<bits/stdc++.h>
using namespace std;
int n,x,ans;
priority_queue<int>pq;
map<int,int>pos;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		pos[x]=i%2;
		pq.push(-x);	
	}
	for(int i=1;i<=n;i+=2)
	{
		if(!pos[-pq.top()])ans++;
		pq.pop();
		if(!pq.empty())pq.pop();
	}
	printf("%d",ans);
}