import java.util.Scanner

import scala.collection.mutable.LinkedHashMap

object Main {
    case class SuspectedMap(key:Int , count:Int)
    implicit def tupleToName(tup: (Int, Int)): SuspectedMap = tup match {
        case (key, count) => SuspectedMap(key, count)
    }

    def main(args: Array[String]): Unit = {
        val scanner = new Scanner(System.in)
        val n: Int = scanner.nextInt
        val vs: List[Int] = List.fill(n)(scanner.nextInt)
        println(calc(vs))
    }

    def calc(nums: List[Int] ): Int ={
        val (evens, odds) = nums.zipWithIndex.partition(_._2 % 2 == 0)
        val (evensFirst, evensSecond) = take2(evens)
        val (oddsFirst, oddsSecond) = take2(odds)

        if (evensSecond.key == -1 && oddsSecond.key == -1){
          if (evensFirst.key != oddsFirst.key) 0
          else nums.sum / 2
        }
        else {
          if (evensFirst.key != oddsFirst.key)
            nums.sum - evensFirst.count - oddsFirst.count
          else
            countMinNumberOfRewrite(nums.sum, evensFirst.count, evensSecond.count, oddsFirst.count, oddsSecond.count)
        }
    }

    def take2(nums: List[(Int, Int)]): ((Int,Int),(Int,Int)) = {
      val sortedNums: Seq[(Int, Int)] = nums.map(_._1).groupBy(n => n).mapValues(_.length).toSeq.sortBy(_.count).reverse
      (sortedNums(0), try{sortedNums(1)}catch{case e :Exception => (-1, Int.MinValue)})
    }

    def countMinNumberOfRewrite(allNums: Int ,e1stCnt: Int, e2ndCnt: Int, o1stCnt: Int, o2ndCnt: Int): Int={
      val count1 = allNums - e1stCnt - o2ndCnt
      val count2 = allNums - e2ndCnt - o1stCnt
      count1.min(count2)
    }
}