import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

class Node{
	int id;
	long value;
	this(int id, long v){
		this.id = id;
		this.value = v;
		}
	}

void main(){
	int n = readln.chomp.to!int;
	Node[] as;
	foreach(i; 0 .. n){
		as ~= new Node(i, readln.chomp.to!long);
		}
	
	as.sort!("a.value < b.value")();
	
	int ans = 0;
	for(int i = 0; i < as.length; i += 2){
		if(i % 2 != as[i].id % 2) ans += 1;
		}
	
	ans.writeln;
	
	}