N = int(eval(input()))

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



se = set()

dic = dict()



for i in range(N):

    if A[i] in se:

        dic[A[i]] += 1

    else:

        se.add(A[i])

        dic.update({A[i]: 1})



c = 0

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

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



result = [0]*N

for i in range(N):

    result[i] = c - (dic[A[i]])*(dic[A[i]]-1)//2 + (dic[A[i]]-1)*(dic[A[i]]-2)//2



print(("\n".join(list(map(str, result)))))

N = int(eval(input()))

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



se = set()

dic = dict()



for i in range(N):

    if A[i] in se:

        dic[A[i]] += 1

    else:

        se.add(A[i])

        dic.update({A[i]: 1})



c = 0

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

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



for i in range(N):

    print((c - dic[A[i]]+1))

N = int(eval(input()))
A = list(map(int, input().split()))
se = set()
dic = dict()
for i in range(N):
    if A[i] in se:
        dic[A[i]] += 1
    else:
        se.add(A[i])
        dic.update({A[i]: 1})
c = 0
for k in list(dic.keys()):
    c += (dic[k]) * (dic[k] - 1) // 2
result = [0] * N
for i in range(N):
    result[i] = (
        c - (dic[A[i]]) * (dic[A[i]] - 1) // 2 + (dic[A[i]] - 1) * (dic[A[i]] - 2) // 2
    )
print(("\n".join(list(map(str, result)))))

N = int(eval(input()))
A = list(map(int, input().split()))
se = set()
dic = dict()
for i in range(N):
    if A[i] in se:
        dic[A[i]] += 1
    else:
        se.add(A[i])
        dic.update({A[i]: 1})
c = 0
for k in list(dic.keys()):
    c += (dic[k]) * (dic[k] - 1) // 2
for i in range(N):
    print((c - dic[A[i]] + 1))

-result = [0] * N -    result[i] = ( -        c - (dic[A[i]]) * (dic[A[i]] - 1) // 2 + (dic[A[i]] - 1) * (dic[A[i]] - 2) // 2 -    ) -print(("\n".join(list(map(str, result))))) +    print((c - dic[A[i]] + 1))