let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = read_line () |> split_string ~pattern:" " |> List.map int_of_string

module IntMap = Map.Make(struct type t = int let compare = compare end)

let map = List.fold_left (fun map i ->
  let cnt = try IntMap.find i map with Not_found -> 0 in
  IntMap.add i (cnt + 1) map
) IntMap.empty a

let () = Printf.printf "%d\n" @@ 
  IntMap.fold (fun i cnt sum -> sum + if i <= cnt then cnt - i else cnt) map 0