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

let cnt = a 
  |> List.sort compare
  |> List.fold_left (fun acc n ->
    match acc with
      | [] -> [(n, 1)]
      | (v, cnt) as t :: xs -> if v = n then (v, cnt + 1) :: xs else (n, 1) :: t :: xs
  ) []

let sum = List.fold_left (fun sum (_, cnt) -> sum + cnt * (cnt - 1) / 2) 0 cnt

let () = List.iter(fun i ->
  Printf.printf "%d\n" @@ sum - List.assoc i cnt + 1
) a