N=int(eval(input()))

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

A1=sorted(A)

cnt=[0 for _ in range(N+1)] #cnt_table[i]: 数字iの要素の個数



for i in range(N):

    cnt[A[i]]+=1



cmb=[cnt[k]*(cnt[k]-1)//2 for k in range(N+1)]

SUM=sum(cmb)



for j in range(N):

    n=A[j]

    v=cnt[A[j]]

    print((SUM-cmb[n]+(v-1)*(v-2)//2))

N=int(eval(input()))

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

cnt=[0 for _ in range(N+1)]

for i in range(N):

    cnt[A[i]]+=1

cmb=[cnt[k]*(cnt[k]-1)//2 for k in range(N+1)]

SUM=sum(cmb)

for j in range(N):

    n=A[j]

    v=cnt[A[j]]

    print((SUM-cmb[n]+(v-1)*(v-2)//2))
N = int(eval(input()))
A = list(map(int, input().split()))
A1 = sorted(A)
cnt = [0 for _ in range(N + 1)]  # cnt_table[i]: 数字iの要素の個数
for i in range(N):
    cnt[A[i]] += 1
cmb = [cnt[k] * (cnt[k] - 1) // 2 for k in range(N + 1)]
SUM = sum(cmb)
for j in range(N):
    n = A[j]
    v = cnt[A[j]]
    print((SUM - cmb[n] + (v - 1) * (v - 2) // 2))

N = int(eval(input()))
A = list(map(int, input().split()))
cnt = [0 for _ in range(N + 1)]
for i in range(N):
    cnt[A[i]] += 1
cmb = [cnt[k] * (cnt[k] - 1) // 2 for k in range(N + 1)]
SUM = sum(cmb)
for j in range(N):
    n = A[j]
    v = cnt[A[j]]
    print((SUM - cmb[n] + (v - 1) * (v - 2) // 2))

-A1 = sorted(A) -cnt = [0 for _ in range(N + 1)]  # cnt_table[i]: 数字iの要素の個数 +cnt = [0 for _ in range(N + 1)]