from collections import Counter



N = int(eval(input()))

*l, = list(map(int, input().split()))

c = Counter(l)



v = 0

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

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



for i in l:

    print((v-(c[i]*(c[i]-1)//2)+((c[i]-1)*(c[i]-2)//2)))
from collections import Counter



N = int(eval(input()))

*A, = list(map(int, input().split()))

c = Counter(A)



ans = 0

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

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



for i in A:

    b = ans

    b -= c[i]*(c[i]-1)//2

    b += (c[i]-1)*(c[i]-2)//2

    print(b)
from collections import Counter

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

from collections import Counter

N = int(eval(input()))
(*A,) = list(map(int, input().split()))
c = Counter(A)
ans = 0
for i in list(c.values()):
    ans += i * (i - 1) // 2
for i in A:
    b = ans
    b -= c[i] * (c[i] - 1) // 2
    b += (c[i] - 1) * (c[i] - 2) // 2
    print(b)

-(*l,) = list(map(int, input().split())) -c = Counter(l) -v = 0 +(*A,) = list(map(int, input().split())) +c = Counter(A) +ans = 0 -    v += i * (i - 1) // 2 -for i in l: -    print((v - (c[i] * (c[i] - 1) // 2) + ((c[i] - 1) * (c[i] - 2) // 2))) +    ans += i * (i - 1) // 2 +for i in A: +    b = ans +    b -= c[i] * (c[i] - 1) // 2 +    b += (c[i] - 1) * (c[i] - 2) // 2 +    print(b)