#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n;
  cin>>n;
  vector<P> vec;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    vec.push_back(P(a,i));
  }
  sort(vec.begin(),vec.end());
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=max(vec[i].second-i,i-vec[i].second)%2;
  }
  cout<<ans/2<<endl;
}
