object Main extends App {	
  val n = readLine.toInt
  val in = readLine.split(" ").map(_.toInt)
  val left = (0 to n - 1 by 2).map(i => in(i)).toSet.toList
  val right = (1 to n - 1 by 2).map(i => in(i)).toSet.toList
  println(if(left == right) n / 2 else left.length - 1 + right.length - 1)
}