from collections import Counter

n = int(eval(input()))

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

A = Counter(a)



X = 0

for x, y in list(A.items()):

    X += y * (y-1) // 2



for i in range(n):

    N = a[i]

    ans = X

    if A[N] >= 2:

        ans -= A[N] * (A[N]-1) // 2 

        ans += (A[N]-1) * (A[N]-2) // 2

    print(ans)
from collections import Counter

n = int(eval(input()))

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

a = {}

ANS = 0

for x,y in list(Counter(A).items()):

    if y >= 2: 

        a[x] = [y, (y*(y-1))//2]

        ANS += (y*(y-1))//2

for i in range(n):

    ans = ANS

    if A[i] in a:

        x = a[A[i]][0]-1

        ans -= a[A[i]][1]

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

    print(ans)
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
A = Counter(a)
X = 0
for x, y in list(A.items()):
    X += y * (y - 1) // 2
for i in range(n):
    N = a[i]
    ans = X
    if A[N] >= 2:
        ans -= A[N] * (A[N] - 1) // 2
        ans += (A[N] - 1) * (A[N] - 2) // 2
    print(ans)

from collections import Counter

n = int(eval(input()))
A = list(map(int, input().split()))
a = {}
ANS = 0
for x, y in list(Counter(A).items()):
    if y >= 2:
        a[x] = [y, (y * (y - 1)) // 2]
        ANS += (y * (y - 1)) // 2
for i in range(n):
    ans = ANS
    if A[i] in a:
        x = a[A[i]][0] - 1
        ans -= a[A[i]][1]
        ans += (x * (x - 1)) // 2
    print(ans)

-a = list(map(int, input().split())) -A = Counter(a) -X = 0 -for x, y in list(A.items()): -    X += y * (y - 1) // 2 +A = list(map(int, input().split())) +a = {} +ANS = 0 +for x, y in list(Counter(A).items()): +    if y >= 2: +        a[x] = [y, (y * (y - 1)) // 2] +        ANS += (y * (y - 1)) // 2 -    N = a[i] -    ans = X -    if A[N] >= 2: -        ans -= A[N] * (A[N] - 1) // 2 -        ans += (A[N] - 1) * (A[N] - 2) // 2 +    ans = ANS +    if A[i] in a: +        x = a[A[i]][0] - 1 +        ans -= a[A[i]][1] +        ans += (x * (x - 1)) // 2