import Data.List (group, sort)

main :: IO ()
main = do
    (_:as) <- getParams
    print $ solve as

getParams :: IO [Int]
getParams = map read . words <$> getContents

solve :: [Int] -> Int
solve = sum . map numDrop . group . sort

numDrop :: [Int] -> Int
numDrop xxs@(x:xs)
  | len < x   = len
  | otherwise = len - x
  where
    len = length xxs
