N = int(eval(input()))

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

c = [0] * (N + 1)

for a in A:

    c[a] += 1

total = sum([n * (n - 1) // 2 for n in c])

for a in A:

    print((total - (c[a] - 1)))
N = int(eval(input()))

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



dupcount = [0] * (N + 1)

for a in A:

    dupcount[a] += 1



allc = 0

for a in range(1, N + 1):

    c = dupcount[a]

    if c > 1:

        allc += (c * (c - 1) // 2)



for a in A:

    ans = allc

    c = dupcount[a]

    if c > 0:

        ans -= (c - 1)

    print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
c = [0] * (N + 1)
for a in A:
    c[a] += 1
total = sum([n * (n - 1) // 2 for n in c])
for a in A:
    print((total - (c[a] - 1)))

N = int(eval(input()))
A = tuple(map(int, input().split()))
dupcount = [0] * (N + 1)
for a in A:
    dupcount[a] += 1
allc = 0
for a in range(1, N + 1):
    c = dupcount[a]
    if c > 1:
        allc += c * (c - 1) // 2
for a in A:
    ans = allc
    c = dupcount[a]
    if c > 0:
        ans -= c - 1
    print(ans)

-A = list(map(int, input().split())) -c = [0] * (N + 1) +A = tuple(map(int, input().split())) +dupcount = [0] * (N + 1) -    c[a] += 1 -total = sum([n * (n - 1) // 2 for n in c]) +    dupcount[a] += 1 +allc = 0 +for a in range(1, N + 1): +    c = dupcount[a] +    if c > 1: +        allc += c * (c - 1) // 2 -    print((total - (c[a] - 1))) +    ans = allc +    c = dupcount[a] +    if c > 0: +        ans -= c - 1 +    print(ans)