import Control.Monad
import Data.List
import qualified Data.IntSet as IntSet

main :: IO ()
main = do
  n <- readLn :: IO Int
  ss <- fmap (map read . words) getLine :: IO [Int]
  print $ solve ss

solve :: [Int] -> Int
solve ss
  | IntSet.size uniques == 1 = length ss `div` 2
  | otherwise = minimum $ map (countNotEqual ss) $ candidates uniques
  where
    uniques = IntSet.fromList ss

candidates :: IntSet.IntSet -> [[Int]]
candidates us = map toInf pairs
  where
    pairs = filter (\(a:b:_) -> not (a == b)) $ replicateM 2 $ IntSet.toList us
toInf :: [Int] -> [Int]
toInf pair = pair ++ (toInf pair)

countNotEqual :: [Int] -> [Int] -> Int
countNotEqual _ [] = 0
countNotEqual [] _ = 0
countNotEqual (a:as) (b:bs) = (if a == b then 0 else 1) + (countNotEqual as bs)
