import Data.List
 
main = do
  getLine
  xs <- map read . words <$> getLine :: IO [Int]
  let a = map (\x -> (head x, length x)) . group . sort $ xs
  print $ solve a
 
solve :: [(Int, Int)] -> Int
solve [] = 0
solve (x:xs)
  | snd x >= fst x = snd x - fst x + solve xs
  | otherwise      = snd x + solve xs