N = int(input())

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

from collections import Counter

ctr = Counter(A)

al = 0

for v in ctr.values():

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



ans = []

for a in A:

    ans.append(al - ctr[a] + 1)

print(*ans, sep='\n')

N = int(input())

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

from collections import Counter

ctr = Counter(A)

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



ans = []

for a in A:

    ans.append(full - ctr[a] + 1)

print(*ans, sep='\n')

N = int(input())
A = list(map(int, input().split()))
from collections import Counter

ctr = Counter(A)
al = 0
for v in ctr.values():
    al += v * (v - 1) // 2
ans = []
for a in A:
    ans.append(al - ctr[a] + 1)
print(*ans, sep="\n")

N = int(input())
A = list(map(int, input().split()))
from collections import Counter

ctr = Counter(A)
full = sum(v * (v - 1) // 2 for v in ctr.values())
ans = []
for a in A:
    ans.append(full - ctr[a] + 1)
print(*ans, sep="\n")

-al = 0 -for v in ctr.values(): -    al += v * (v - 1) // 2 +full = sum(v * (v - 1) // 2 for v in ctr.values()) -    ans.append(al - ctr[a] + 1) +    ans.append(full - ctr[a] + 1)