module Main where

import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.IntMap.Strict as M

f k v acc
    | k == v = acc
    | k >  v = v + acc
    | k <  v = (v - k) + acc

main :: IO ()
main = do
    getLine
    im <- M.fromListWith (+) . flip zip (repeat (1 :: Int))
            . fmap read . words <$> getLine
    let ans = M.foldrWithKey f 0 im
    print ans