#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define SP fixed << setprecision(10)
#define ER(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long ll;
typedef pair <int , int> pii;
typedef double DB;

const int N = 100100;
pii a[N];

int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	
	int n , t(0);
	cin >> n;

	for(int i = 0 ; i < n ; i++){
		cin >> a[i].F;
		a[i].S = i;
	}
	
	sort(a , a+n);

	for(int i = 0 ; i < n ; i++){
		if(a[i].S%2 != i%2){
			t++;
		}
	}

	cout << t/2 << endl;

	return 0;
}
