import Data.List

(|>) :: a -> (a -> b) -> b
infixl 1 |>
x |> f = f x

($>) :: (Functor m) => m a -> (a -> b) -> m b
infixl 1 $>
x $> f = fmap f x

calc :: [Int] -> Int
calc xs = let len = length xs
              num = xs !! 0
              in (if len >= num then len - num else len)

main = do
    n <- getLine
    ax <- getLine $> words $> map read :: IO [Int]
    ax |> sort |> group |> map calc |> sum |> print