import Data.List
import Data.Bool

main = do
    getLine
    xs <- map read . words <$> getLine
    let xs' = map (\xx -> (head xx, length xx)) . group . sort $ xs
        result = sum . map (\(x,n) -> bool (n-x) n $ n < x) $ xs'
    print result
