let _n = stdin.ReadLine() |> int64
let _a = stdin.ReadLine().Split() 

let memoize fn = 
    let cache = new System.Collections.Generic.Dictionary<_,_>()
    (fun x ->
    match cache.TryGetValue x with
    | true, v -> v
    | false, _ -> 
        let v = fn (x)
        cache.Add(x,v)
        v)

/// nC2
let c2 n = n * (n - 1L) / 2L
let memC2 = memoize c2

let countByA =  _a |> Array.countBy id

/// それぞれの答え
let ansEach aNum = 
    countByA
    |> Seq.map (fun (aKey, count) ->
        if aKey = aNum then
            int64 (count-1)
        else 
            int64 count)
    |> Seq.map memC2
    |> Seq.sum
    |> string

_a
|> Seq.map ansEach
|> Seq.iter stdout.WriteLine