import Data.List
import Debug.Trace

main = do
  _ <- getLine
  as <- map read . words <$> getLine :: IO [Int]
  print $ solve as

solve as =
  ans 
  where
    grp = group $ sort as
    check [] acc = acc
    check as@(a:_) acc =
      let len = length a in
      let diff = len - head a in
      let del = if diff >= 0 then diff else len in
      traceShow (a,len,diff,del) $
      check (tail as) (acc+del)
    ans = check grp 0