#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;

int n;
int a[101010];
vector<P> b;

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    b.push_back(P(a[i], i));
  }

  sort(b.begin(), b.end());

  int cnt = 0;
  for (int i = 0; i < b.size(); i++){
    if (b[i].second % 2 != i % 2) cnt++;
  }

  cout << cnt / 2 << endl;
}

