n=int(eval(input()))

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

ma=int(200200)

B=[0]*ma



for i in range(n):

    now=A[i]

    B[now]+=1



ans=int(0)

for i in range(ma):

    ans+=int((B[i]-1)*B[i]/2)



for i in range(n):

    now=A[i]

    Ans=ans

    Ans-=int((B[now]-1)*B[now]/2)

    Ans+=int((B[now]-1)*(B[now]-2)/2)

    print(Ans)
n=int(eval(input()))

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

ma=int(200200)

B=[0]*ma



for i in range(n):

    B[A[i]]+=1



ans=int(0)

for i in range(ma):

    ans+=int((B[i]-1)*B[i]/2)



for i in range(n):

    print((ans-B[A[i]]+1))
n = int(eval(input()))
A = list(map(int, input().split()))
ma = int(200200)
B = [0] * ma
for i in range(n):
    now = A[i]
    B[now] += 1
ans = int(0)
for i in range(ma):
    ans += int((B[i] - 1) * B[i] / 2)
for i in range(n):
    now = A[i]
    Ans = ans
    Ans -= int((B[now] - 1) * B[now] / 2)
    Ans += int((B[now] - 1) * (B[now] - 2) / 2)
    print(Ans)

n = int(eval(input()))
A = list(map(int, input().split()))
ma = int(200200)
B = [0] * ma
for i in range(n):
    B[A[i]] += 1
ans = int(0)
for i in range(ma):
    ans += int((B[i] - 1) * B[i] / 2)
for i in range(n):
    print((ans - B[A[i]] + 1))

-    now = A[i] -    B[now] += 1 +    B[A[i]] += 1 -    now = A[i] -    Ans = ans -    Ans -= int((B[now] - 1) * B[now] / 2) -    Ans += int((B[now] - 1) * (B[now] - 2) / 2) -    print(Ans) +    print((ans - B[A[i]] + 1))