M=int(eval(input()))

N=list(input().split())

check=[0]*M

for i in range(M):

    check[int(N[i])-1]+=1

num=0

for i in range(M):

    num+=check[i]*(check[i]-1)//2

for i in range(M):

    if check[int(N[i])-1]!=2:

        print((num-(check[int(N[i])-1]-1)))

    else:

        print((num-1))

M=int(eval(input()))

N=list(input().split())

check=[0]*M

for i in range(M):

    check[int(N[i])-1]+=1

num=0

for i in range(M):

    num+=check[i]*(check[i]-1)//2

for i in range(M):

    #if check[int(N[i])-1]!=2:

    print((num-(check[int(N[i])-1]-1)))

    #else:

       # print(num-1)
M = int(eval(input()))
N = list(input().split())
check = [0] * M
for i in range(M):
    check[int(N[i]) - 1] += 1
num = 0
for i in range(M):
    num += check[i] * (check[i] - 1) // 2
for i in range(M):
    if check[int(N[i]) - 1] != 2:
        print((num - (check[int(N[i]) - 1] - 1)))
    else:
        print((num - 1))

M = int(eval(input()))
N = list(input().split())
check = [0] * M
for i in range(M):
    check[int(N[i]) - 1] += 1
num = 0
for i in range(M):
    num += check[i] * (check[i] - 1) // 2
for i in range(M):
    # if check[int(N[i])-1]!=2:
    print((num - (check[int(N[i]) - 1] - 1)))
    # else:
    # print(num-1)

-    if check[int(N[i]) - 1] != 2: -        print((num - (check[int(N[i]) - 1] - 1))) -    else: -        print((num - 1)) +    # if check[int(N[i])-1]!=2: +    print((num - (check[int(N[i]) - 1] - 1))) +    # else: +    # print(num-1)