import qualified Data.IntMap as M

main = do
  getLine
  as <- map read . words <$> getLine
  print $ solve as

solve = calc . count

count as = fromListWith (+) $ zip as (repeat 1)

calc = M.foldrWithKey op 0

op k v s
  | k <= v = s + v - k
  | otherwise = s + v