{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as M

main = do
    n <- readLn :: IO Int
    print =<< sum.map (\(k,a)->if a>k then a-k else if a/=k then a else 0).M.toList.foldl' (\m k -> M.insertWith(+)k 1 m) M.empty.unfoldr (B.readInt.B.dropWhile(==' ')) <$> B.getLine
