object Main extends App {
  println((for (_ ← 1 to scala.io.StdIn.readInt) yield (scala.io.StdIn.readInt)).toList.zipWithIndex.sortBy {
    case (f, i) ⇒ f
  }.map { _._2 % 2 == 0 }.foldLeft(true, 0) {
    case ((parity, res), idx) ⇒ if (parity == idx) (!parity, res) else (!parity, res + 1)
  }._2 / 2)
}