n=int(eval(input()))

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

import collections

c = collections.Counter(l)

ans=0

for v in list(c.values()):

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

for x in l:

  print((ans-c[x]*(c[x]-1)//2+(c[x]-1)*(c[x]-2)//2))
n=int(eval(input()))

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

import collections

c = collections.Counter(l)

ans=0

for v in list(c.values()):

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

for x in l:

  print((ans-c[x]+1))
n = int(eval(input()))
l = list(map(int, input().split()))
import collections

c = collections.Counter(l)
ans = 0
for v in list(c.values()):
    ans += v * (v - 1) // 2
for x in l:
    print((ans - c[x] * (c[x] - 1) // 2 + (c[x] - 1) * (c[x] - 2) // 2))

n = int(eval(input()))
l = list(map(int, input().split()))
import collections

c = collections.Counter(l)
ans = 0
for v in list(c.values()):
    ans += v * (v - 1) // 2
for x in l:
    print((ans - c[x] + 1))

-    print((ans - c[x] * (c[x] - 1) // 2 + (c[x] - 1) * (c[x] - 2) // 2)) +    print((ans - c[x] + 1))