#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int n, a[100010], b[100010], ans;
map<int, int> mp;
int main()
{
    scanf("%d", &n);
    for(int i = 0 ; i < n ; i++ ) scanf("%d", a+i), b[i] = a[i], mp[a[i]] = i;
    sort(b, b+n);
    for(int i = 0 ; i < n ; i++ ) if( i%2 != mp[b[i]]%2 ) ans++;
    printf("%d", ans/2);
    return 0;
}
