import Data.Map as Map (Map, lookup, insert, empty, toList) 
 
main = do
  n <- getLine
  xs <- map read . words <$> getLine
  putStrLn . show $ solve' xs

solve' :: [Int] -> Int
solve' xs = 
  let kv = toList $ solve xs empty
  in sum $ map (\(k,v) -> if k > v then v else v-k) kv
  
solve :: [Int] -> Map.Map Int Int -> Map.Map Int Int
solve [] mp = mp
solve (x:xs) mp = 
  case Map.lookup x mp of
    Nothing -> solve xs (insert x 1 mp)
    Just v -> solve xs (insert x (v+1) mp)
