n=int(eval(input()))

#a,b=map(int,input().split())

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

#l=[list(map(int,input().split())) for i in range(n)]



dic={}



for a in al:

    dic[a]=dic.get(a,0)+1

total=0

for k in list(dic.keys()):

    total+=dic[k]*(dic[k]-1)//2



for k in range(n):

    count=dic[al[k]]

    ans=total-count*(count-1)//2+(count-1)*(count-2)//2

    print(ans)

n=int(eval(input()))

#n,p=map(int,input().split())

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

#l=[list(map(int,input().split())) for i in range(n)]



dic={}

for a in al:

    dic[a]=dic.get(a,0)+1

total=0

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

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



for k in range(n):

    res=total-(dic[al[k]]-1)

    print(res)



n = int(eval(input()))
# a,b=map(int,input().split())
al = list(map(int, input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
dic = {}
for a in al:
    dic[a] = dic.get(a, 0) + 1
total = 0
for k in list(dic.keys()):
    total += dic[k] * (dic[k] - 1) // 2
for k in range(n):
    count = dic[al[k]]
    ans = total - count * (count - 1) // 2 + (count - 1) * (count - 2) // 2
    print(ans)

n = int(eval(input()))
# n,p=map(int,input().split())
al = list(map(int, input().split()))
# l=[list(map(int,input().split())) for i in range(n)]
dic = {}
for a in al:
    dic[a] = dic.get(a, 0) + 1
total = 0
for v in list(dic.values()):
    total += v * (v - 1) // 2
for k in range(n):
    res = total - (dic[al[k]] - 1)
    print(res)

-# a,b=map(int,input().split()) +# n,p=map(int,input().split()) -for k in list(dic.keys()): -    total += dic[k] * (dic[k] - 1) // 2 +for v in list(dic.values()): +    total += v * (v - 1) // 2 -    count = dic[al[k]] -    ans = total - count * (count - 1) // 2 + (count - 1) * (count - 2) // 2 -    print(ans) +    res = total - (dic[al[k]] - 1) +    print(res)