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

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a))
  |> Array.fold_left (fun m a ->
      IntMap.add a (1 + try IntMap.find a m with Not_found -> 0) m)
      IntMap.empty
  |> IntMap.bindings
  |> List.map (fun (a, x) -> if a <= x then x - a else x)
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n"