import collections

import math



def cmb_factorial(s):

    return math.factorial(s) // (math.factorial(2) * math.factorial(s - 2))



n = int(eval(input()))

a = list(map(int, input().split()))

c = collections.Counter(a)

f = {}



cmb = 0

for x in list(c.values()):

    f[1] = 0

    f[2] = 1

    if x >= 3:

        f[x] = cmb_factorial(x)

        if x - 1 not in f:

            f[x - 1] = cmb_factorial(x - 1)

    cmb += f.get(x)



for z in a:

    y = c.get(z)

    ans = cmb

    if y >= 2:

        ans = cmb - f.get(y) + f.get(y - 1)

    print(ans)
import collections



n = int(eval(input()))

a = list(map(int, input().split()))

c = collections.Counter(a)



cmb = 0

for x in list(c.values()):

    cmb += x * (x - 1) // 2

    

for z in a:

    y = c.get(z)

    before = y * (y - 1) // 2

    after = (y - 1) * (y - 2) //2

    ans = cmb - before + after

    print(ans)
import collections
import math


def cmb_factorial(s):
    return math.factorial(s) // (math.factorial(2) * math.factorial(s - 2))


n = int(eval(input()))
a = list(map(int, input().split()))
c = collections.Counter(a)
f = {}
cmb = 0
for x in list(c.values()):
    f[1] = 0
    f[2] = 1
    if x >= 3:
        f[x] = cmb_factorial(x)
        if x - 1 not in f:
            f[x - 1] = cmb_factorial(x - 1)
    cmb += f.get(x)
for z in a:
    y = c.get(z)
    ans = cmb
    if y >= 2:
        ans = cmb - f.get(y) + f.get(y - 1)
    print(ans)

import collections

n = int(eval(input()))
a = list(map(int, input().split()))
c = collections.Counter(a)
cmb = 0
for x in list(c.values()):
    cmb += x * (x - 1) // 2
for z in a:
    y = c.get(z)
    before = y * (y - 1) // 2
    after = (y - 1) * (y - 2) // 2
    ans = cmb - before + after
    print(ans)

-import math - - -def cmb_factorial(s): -    return math.factorial(s) // (math.factorial(2) * math.factorial(s - 2)) - -f = {} -    f[1] = 0 -    f[2] = 1 -    if x >= 3: -        f[x] = cmb_factorial(x) -        if x - 1 not in f: -            f[x - 1] = cmb_factorial(x - 1) -    cmb += f.get(x) +    cmb += x * (x - 1) // 2 -    ans = cmb -    if y >= 2: -        ans = cmb - f.get(y) + f.get(y - 1) +    before = y * (y - 1) // 2 +    after = (y - 1) * (y - 2) // 2 +    ans = cmb - before + after