import qualified Data.IntMap as M
import qualified Data.ByteString.Char8 as B
import Data.Maybe
 
main = B.getContents >>= print . solve . tail . map readB . B.words

readB = fst . fromJust . B.readInt
 
solve = calc . count
 
count [] = M.empty
count (a:as) = M.insertWith (+) a 1 $ count as
 
calc = M.foldrWithKey op 0
 
op k v s
  | k <= v = s + v - k
  | otherwise = s + v
