c=[0]*8**6

_,a=open(0)

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

for i in a:c[i]+=1

s=sum(i*~-i//2for i in c)

for i in a:print((s-c[i]+1))
c=[0]*8**6

_,a=open(0)

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

for i in a:c[i]+=1

s=sum(i*~-i//2for i in c)

print((' '.join(str(s-c[i]+1)for i in a)))
c = [0] * 8**6
_, a = open(0)
(*a,) = list(map(int, a.split()))
for i in a:
    c[i] += 1
s = sum(i * ~-i // 2 for i in c)
for i in a:
    print((s - c[i] + 1))

c = [0] * 8**6
_, a = open(0)
(*a,) = list(map(int, a.split()))
for i in a:
    c[i] += 1
s = sum(i * ~-i // 2 for i in c)
print((" ".join(str(s - c[i] + 1) for i in a)))

-for i in a: -    print((s - c[i] + 1)) +print((" ".join(str(s - c[i] + 1) for i in a)))