// IN THE NAME OF GOD
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
using namespace std;
const int MAXN = 1e5 + 15;
int n, a[MAXN], ans;
map <int, int> pos;
vector <int> vect;
int main(){
  //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i], vect.pb(a[i]);
  sort(vect.begin(), vect.end());
  for(int i = 0; i < vect.size(); i++) pos[vect[i]] = i;
  for(int i = 0; i < n; i++) if(abs(i - pos[a[i]]) % 2) ans++;
  cout << ans / 2 << endl;
}
