import java.io.PrintWriter
import java.util.*

object out : PrintWriter(System.out)

fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val a = IntArray(n) { readLine()!!.toInt() }
    val m = arrayOf(HashMap<Int, Int>(), HashMap<Int, Int>())
    a.forEachIndexed { i, a -> m[i % 2][a] = (m[i % 2][a] ?: 0) + 1 }
    a.sort()
    a.forEachIndexed { i, a -> m[i % 2][a] = (m[i % 2][a] ?: 0) - 1 }
    out.println(m[0].values.map { Math.max(it, 0) }.sum())
    out.close()
}