import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char

main :: IO ()
main = do
  n <- readLn
  vs <- readInts
  print $ solve n vs

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

solve :: Int -> [Int] -> Int
solve n vs = go n (count as) (count bs)
  where (as, bs) = deal vs

count :: [Int] -> [(Int, Int)]
count = sortOn (negate . snd) . map ((,) <$> head <*> length) . group . sort

deal :: [Int] -> ([Int], [Int])
deal [] = ([], [])
deal (x:y:zs) = (x:xs, y:ys)
  where (xs, ys) = deal zs

go :: Int -> [(Int, Int)] -> [(Int, Int)] -> Int
go n [(ka0, va0)] [(kb0, vb0)]
  | ka0 == kb0 = n - va0
  | otherwise = n - va0 - vb0
go n [(ka0, va0)] ((kb0, vb0):(kb1, vb1):_)
  | ka0 == kb0 = n - va0 - vb1
  | otherwise = n - va0 - vb0
go n ((ka0, va0):(ka1, va1):_) [(kb0, vb0)]
  | ka0 == kb0 = n - va1 - vb0
  | otherwise = n - va0 - vb0
go n ((ka0, va0):(ka1, va1):_) ((kb0, vb0):(kb1, vb1):_)
  | ka0 /= kb0 = n - va0 - vb0
  | va0 + vb1 > va1 + vb0 = n - va0 - vb1
  | otherwise = n - va1 - vb0