#include <bits/stdc++.h>
using namespace std;
const int N=5e5;

  int a[N],r[N];
int cmp(int x,int y)
{
  return a[x]<a[y];
}

  int n,A;
int main()
{
  cin>>n;
  for (int i=0;++i<=n;)
    scanf("%d",a+i),
		r[i]=i;
  sort(r+1,r+n+1,cmp);
  for (int i=0;++i<=n;)
    A+=r[i]&1^i&1;
  cout<<A/2;
  exit(0);
}
