import Data.HashMap

main = do
  n <- getLine
  xs <- map read . words <$> getLine
  putStrLn . show $ solve xs

solve :: [Int] -> Map Int Int -> Int
solve [] mp = 0
solve (x:xs) mp = 
  let res = case lookup x mp of
    Nothing -> solve xs (insert x 1 mp)
    Just v -> (if v >= x then 1 else 0) + (solve xs (insert x (v+1) mp))

