#include <stdio.h>
#include <map>
using namespace std;

map<int, int> red;
int N,A[100000];

int main()
{
	scanf ("%d",&N);
	int cnt = 0;
	for (int i=0;i<N;i++){
		scanf ("%d",&A[i]);
		red[A[i]] = 0;
	}
	int v = 0;
	for (auto &p : red) p.second = v++;
	for (int i=0;i<N;i++){
		if (red[A[i]] % 2 != i % 2) cnt++;
	}
	printf ("%d\n",cnt/2);

	return 0;
}