
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f

let () =
  let n = read_int () in
  let xs = read_ints n in
  let cs = Array.make 100002 0 in
  flip List.iter xs (fun x ->
    let i = min 100001 x in cs.(i) <- cs.(i) + 1);
  for_iter 0 100002 (fun i -> if i <= cs.(i) then cs.(i) - i else cs.(i))
  |> List.fold_left (+) 0
  |> printf "%d\n"
