import scala.io.StdIn

object Main {
    def main(args: Array[String]) = {
        StdIn.readLine()
        val a = StdIn.readLine().split(" ").toList.map { str: String => str.toInt }

        def getAlternateIndex(intList: List[Int], result: List[Int] = Nil): List[Int] = intList match {
                case Nil => result.reverse
                case int :: tail => getAlternateIndex(tail.drop(1), int :: result)
        }

        val evenA = getAlternateIndex(a)
        val oddA  = getAlternateIndex(a.drop(1))

        println(evenA.toSet.size-1 + oddA.toSet.size-1 match {
            case x: Int if x < 0 => 0
            case x: Int if (evenA ::: oddA).toSet.size == 1 => evenA.size
            case x => x
        })
    }
}
