import Data.List

main::IO()
main = do
    n <- readLn::IO Int
    xs <-map read . words <$> getLine::IO [Int] 
    print $ (query . group . sort) xs

query::[[Int]] -> Int
query[] = 0
query (x:xs) = if x!!0 == length x then query xs
                  else sbtrct x + query xs  

sbtrct::[Int] -> Int
sbtrct x = if length x <= x!!0 then length x 
              else (length x) - (x!!0)

