object Main extends App {
	val n = scala.io.StdIn.readInt
	var a = List[Long]()
	var b = List[Long]()

	for(i<-0 until n){
		if(i%2 == 0) a = scala.io.StdIn.readLong :: a
		else  b = scala.io.StdIn.readLong :: b
	}

	a = a.sorted
	b = b.sorted

	val t = new Array[Long](n)

	for(i<-0 until n){
		if(i%2 == 0){
			t(i) = a.head
			a = a.tail
		}else{
			t(i) = b.head
			b = b.tail
		}
	}
	var ans = 0
	for(i<-0 until n-1){
		if(t(i) > t(i+1)){
			val tp = t(i)
			t(i) = t(i+1)
			t(i+1) = tp
			ans += 1
		}
	}


	println(ans)

}
