from collections import Counter



N, *A = list(map(int, open(0).read().split()))

ctr = Counter(A)

total = sum(v * (v - 1) // 2 for v in list(ctr.values()))

for v in A:

    c = ctr[v]

    print((total - (c * (c - 1) // 2) + max(0, (c - 1) * (c - 2) // 2)))



from collections import Counter



N = int(eval(input()))

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

ctr = Counter(X)



ans = 0

for v in list(ctr.values()):

    ans += v * (v - 1) // 2



for i in range(N):

    val = ctr[X[i]]

    print((ans - val * (val - 1) // 2 + (val - 1) * (val - 2) // 2))

from collections import Counter

N, *A = list(map(int, open(0).read().split()))
ctr = Counter(A)
total = sum(v * (v - 1) // 2 for v in list(ctr.values()))
for v in A:
    c = ctr[v]
    print((total - (c * (c - 1) // 2) + max(0, (c - 1) * (c - 2) // 2)))

from collections import Counter

N = int(eval(input()))
X = list(map(int, input().split()))
ctr = Counter(X)
ans = 0
for v in list(ctr.values()):
    ans += v * (v - 1) // 2
for i in range(N):
    val = ctr[X[i]]
    print((ans - val * (val - 1) // 2 + (val - 1) * (val - 2) // 2))

-N, *A = list(map(int, open(0).read().split())) -ctr = Counter(A) -total = sum(v * (v - 1) // 2 for v in list(ctr.values())) -for v in A: -    c = ctr[v] -    print((total - (c * (c - 1) // 2) + max(0, (c - 1) * (c - 2) // 2))) +N = int(eval(input())) +X = list(map(int, input().split())) +ctr = Counter(X) +ans = 0 +for v in list(ctr.values()): +    ans += v * (v - 1) // 2 +for i in range(N): +    val = ctr[X[i]] +    print((ans - val * (val - 1) // 2 + (val - 1) * (val - 2) // 2))