open Hashtbl
let h, ans, a_s = create 0, ref 0, Array.init (read_int ()) @@ fun _ -> Scanf.scanf " %d" (+) 0
let _ = Array.iter (fun a -> replace h a @@ try find h a + 1 with _ -> 1) a_s; iter (fun a c -> ans := !ans + if a > c then c else min c @@ c - a) h; Printf.printf "%d\n" !ans