import scala.io.StdIn._

object Main extends App {
  val n = readInt()
  val v = readLine().split(" ").map(_.toInt).toSeq
  println(v.zipWithIndex.groupBy(_._2 % 2).map(_._2.groupBy(_._1).toSeq.sortBy(_._2.length).init.map(_._2.length).sum).sum)
}
