#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
const int N=1e5+5;
int n,ans;
pair<int,int> a[N];
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i) if((i&1)!=(a[i].second&1)) ++ans;
	cout<<(ans>>1)<<endl;
	return 0;
} 