n = int(eval(input()))

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

num = [0] * n

cnt = 0



for i in a:

    num[i - 1] += 1



for i in num:

    cnt += i * (i - 1)//2



for i in range(n):

    tmp = num[a[i]-1]

    ans = cnt - (tmp * (tmp-1) // 2)

    ans += ((tmp-2) * (tmp-1) // 2)

    print(ans)

n = int(eval(input()))

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

num = [0] * n

cnt = 0



for i in a:

    num[i - 1] += 1



for i in num:

    cnt += i * (i - 1)//2



for i in range(n):

    tmp = num[a[i]-1]

    ans = cnt - ((tmp-(tmp-2)) * (tmp-1) // 2)

    print(ans)

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

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

-    ans = cnt - (tmp * (tmp - 1) // 2) -    ans += (tmp - 2) * (tmp - 1) // 2 +    ans = cnt - ((tmp - (tmp - 2)) * (tmp - 1) // 2)