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

Scanf.scanf "%d" (fun n ->
    let add a map = M.add a (1 + try M.find a map with _ -> 0) map in
    let rec loop i map =
        if i = n then map else
            let map = Scanf.scanf " %d" (fun a -> add a map) in
            loop (i + 1) map
    in
    let map = loop 0 M.empty in
    M.fold (fun k v acc ->
        if v < k then acc + v else acc + v - k) map 0 |> Printf.printf "%d\n"
)