module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    n <- readLn :: IO Int
    vs <- fmap read . words <$> getLine :: IO [Int]
    let xss = sortBy (\a b -> length b `compare` length a) . group . sort $ vs
    case length xss of
        1 -> print $ n `div` 2
        2 -> print 0
        _ -> print $ length . concat $ drop 2 xss
