from collections import Counter

n = int(eval(input()))

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

c = Counter(a)

d = {}

sum = 0

for i in c:

    k = c[i]

    sum += k * (k - 1) / 2

for i in range(n):

    print((int(sum - c[a[i]] + 1)))
N = int(eval(input()))

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



from collections import Counter



c = Counter(L)

d = {}

sum = 0



for i in c:

    k = c[i]

    sum += k * (k-1) //2

for i in range(N):

    print((int(sum - c[L[i]] + 1)))

from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
c = Counter(a)
d = {}
sum = 0
for i in c:
    k = c[i]
    sum += k * (k - 1) / 2
for i in range(n):
    print((int(sum - c[a[i]] + 1)))

N = int(eval(input()))
L = list(map(int, input().split()))
from collections import Counter

c = Counter(L)
d = {}
sum = 0
for i in c:
    k = c[i]
    sum += k * (k - 1) // 2
for i in range(N):
    print((int(sum - c[L[i]] + 1)))

+N = int(eval(input())) +L = list(map(int, input().split())) -n = int(eval(input())) -a = list(map(int, input().split())) -c = Counter(a) +c = Counter(L) -    sum += k * (k - 1) / 2 -for i in range(n): -    print((int(sum - c[a[i]] + 1))) +    sum += k * (k - 1) // 2 +for i in range(N): +    print((int(sum - c[L[i]] + 1)))