n=int(eval(input()))

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

cnt=[0]*(n+1)

for i in range(n):

  cnt[a[i]]+=1

ans=0

for i in range(n+1):

  ans+=cnt[i]*(cnt[i]-1)//2

for i in range(n): 

    print((ans-cnt[a[i]]*(cnt[a[i]]-1)//2+(cnt[a[i]]-1)*(cnt[a[i]]-2)//2))
n=int(eval(input()))

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

d=[0]*(2*10**5+1)

ans=0

for i in a:

  d[i]+=1

for v in d:

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

for i in range(n):

  v=d[a[i]]

  print((ans-v*(v-1)//2+(v-1)*(v-2)//2))
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = [0] * (n + 1)
for i in range(n):
    cnt[a[i]] += 1
ans = 0
for i in range(n + 1):
    ans += cnt[i] * (cnt[i] - 1) // 2
for i in range(n):
    print(
        (
            ans
            - cnt[a[i]] * (cnt[a[i]] - 1) // 2
            + (cnt[a[i]] - 1) * (cnt[a[i]] - 2) // 2
        )
    )

n = int(eval(input()))
a = list(map(int, input().split()))
d = [0] * (2 * 10**5 + 1)
ans = 0
for i in a:
    d[i] += 1
for v in d:
    ans += v * (v - 1) // 2
for i in range(n):
    v = d[a[i]]
    print((ans - v * (v - 1) // 2 + (v - 1) * (v - 2) // 2))

-cnt = [0] * (n + 1) +d = [0] * (2 * 10**5 + 1) +ans = 0 +for i in a: +    d[i] += 1 +for v in d: +    ans += v * (v - 1) // 2 -    cnt[a[i]] += 1 -ans = 0 -for i in range(n + 1): -    ans += cnt[i] * (cnt[i] - 1) // 2 -for i in range(n): -    print( -        ( -            ans -            - cnt[a[i]] * (cnt[a[i]] - 1) // 2 -            + (cnt[a[i]] - 1) * (cnt[a[i]] - 2) // 2 -        ) -    ) +    v = d[a[i]] +    print((ans - v * (v - 1) // 2 + (v - 1) * (v - 2) // 2))