import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sort, group)
import Data.Heap (Heap)
import qualified Data.Heap as H
import Data.Maybe (fromJust)
import Data.Bool (bool)

main :: IO ()
main = do
  let
    unsafeNext :: Heap (H.Entry Int [Int]) -> (Int, Heap (H.Entry Int [Int]))
    unsafeNext = f . fromJust . H.viewMin
      where
        f :: (H.Entry Int [Int], Heap (H.Entry Int [Int])) -> (Int, Heap (H.Entry Int [Int]))
        f (H.Entry x (x' : xs), h) = (x, H.insert (H.Entry x' xs) h)
    f :: [(Int, Int)] -> (Int, Heap (H.Entry Int [Int]))
    f = foldl step (0, H.empty)
      where
        step :: (Int, Heap (H.Entry Int [Int])) -> (Int, Int) -> (Int, Heap (H.Entry Int [Int]))
        step (_, h) (x, l) | H.null h  = (bool l 0 (l == 1), H.insert (H.Entry (2 * x) (map (x *) [3..])) h)
        step (k, h) (x, l) = case compare x y of
                               LT -> (k + bool l 0 (l == 1), H.insert (H.Entry (2 * x) (map (x *) [3..])) h)
                               EQ -> (k + l, h)
                               _  -> step (k, snd . unsafeNext $ h) (x, l)
          where
            H.Entry y _ = H.minimum h :: H.Entry Int [Int]
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print . (n -) . fst . f . map ((,) <$> head <*> length) . group . sort $ as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
