let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let inv_as = Array.make n 0 in
  Array.iter (fun a -> inv_as.(a - 1) <- inv_as.(a - 1) + 1) as_;
  let somme =
    Array.fold_right (fun n -> ( + ) @@ n * (n - 1) / 2) inv_as 0 in
  for i = 0 to n - 1 do
    let n = inv_as.(as_.(i) - 1) in
    Printf.printf "%d\n" @@ somme - n * (n - 1) / 2 + max 0 ((n - 1) * (n - 2) / 2)
  done