#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
typedef pair<int,int> pii;

int main(){
  int n;
  cin>>n;
  vector<pii> vec1;
  int tmp;
  for(int i=0;i<n;i++){
    cin>>tmp;
    vec1.push_back(make_pair(tmp,i));
  }
  sort(vec1.begin(),vec1.end());
  int ans=0;
  for(int i=0;i<n;i+=2)
    if(vec1[i].second%2==1)ans++;
  cout<<ans<<endl;
}