open Batteries

module Intmap = Map.Make(Int)

let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let intmap = Intmap.empty in
  let intmap = List.fold_left (fun accum x -> Intmap.modify_opt x (fun v_opt -> match v_opt with
        Some v -> Some (v+1)
      | None -> Some 1
    ) accum) intmap a_lst
  in
  let assoc = Intmap.bindings intmap in
  let ans = List.map (fun (i,c) -> if i < c then c-i else if i > c then c else 0) assoc |> List.fold_left (+) 0 in

  Printf.printf "%d\n" ans
