n = int(eval(input()))

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

b = [0]*n

ans = 0



for i in range(n):

    b[a[i] - 1] += 1



for i in range(n):

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



for i in range(n):

    print((ans - b[a[i] - 1] + 1))
n = int(eval(input()))

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

d = {}

total = 0



for i in a:

    if i not in d:

        d[i] = 1

    else:

        total += d[i]

        d[i] += 1



for i in range(n):

    ans = total - (d[a[i]] - 1)

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

n = int(eval(input()))
a = list(map(int, input().split()))
d = {}
total = 0
for i in a:
    if i not in d:
        d[i] = 1
    else:
        total += d[i]
        d[i] += 1
for i in range(n):
    ans = total - (d[a[i]] - 1)
    print(ans)

-b = [0] * n -ans = 0 +d = {} +total = 0 +for i in a: +    if i not in d: +        d[i] = 1 +    else: +        total += d[i] +        d[i] += 1 -    b[a[i] - 1] += 1 -for i in range(n): -    ans += b[i] * (b[i] - 1) // 2 -for i in range(n): -    print((ans - b[a[i] - 1] + 1)) +    ans = total - (d[a[i]] - 1) +    print(ans)