from operator import mul

from functools import reduce



def cmb(n):

  return n*(n-1)//2



N=int(eval(input()))

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



#インデックス０は除外

count=[0]*(N+1)

for a in A:

  count[a]+=1



cmbs=[0]*N

for i,c in enumerate(count):

  if i==0:

    continue

  cmbs[i-1]=cmb(c)

SUM=sum(cmbs) 

for i in range(N):

  a=A[i]

  #print(cmbs[a-1])

  ans=SUM-cmbs[a-1]+cmb(count[a]-1)

  print(ans)

  

#print(count, cmbs)
N=int(eval(input()))

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

L=[0]*(max(A)+1)

for a in A:

  L[a]+=1

#print(L)

SUM=0

for l in L:

  SUM+=l*(l-1)//2

  

for a in A:

  l=L[a]

  print((SUM-l*(l-1)//2+(l-1)*(l-2)//2))

  
from operator import mul
from functools import reduce


def cmb(n):
    return n * (n - 1) // 2


N = int(eval(input()))
A = list(map(int, input().split()))
# インデックス０は除外
count = [0] * (N + 1)
for a in A:
    count[a] += 1
cmbs = [0] * N
for i, c in enumerate(count):
    if i == 0:
        continue
    cmbs[i - 1] = cmb(c)
SUM = sum(cmbs)
for i in range(N):
    a = A[i]
    # print(cmbs[a-1])
    ans = SUM - cmbs[a - 1] + cmb(count[a] - 1)
    print(ans)
# print(count, cmbs)

N = int(eval(input()))
A = list(map(int, input().split()))
L = [0] * (max(A) + 1)
for a in A:
    L[a] += 1
# print(L)
SUM = 0
for l in L:
    SUM += l * (l - 1) // 2
for a in A:
    l = L[a]
    print((SUM - l * (l - 1) // 2 + (l - 1) * (l - 2) // 2))

-from operator import mul -from functools import reduce - - -def cmb(n): -    return n * (n - 1) // 2 - - -# インデックス０は除外 -count = [0] * (N + 1) +L = [0] * (max(A) + 1) -    count[a] += 1 -cmbs = [0] * N -for i, c in enumerate(count): -    if i == 0: -        continue -    cmbs[i - 1] = cmb(c) -SUM = sum(cmbs) -for i in range(N): -    a = A[i] -    # print(cmbs[a-1]) -    ans = SUM - cmbs[a - 1] + cmb(count[a] - 1) -    print(ans) -# print(count, cmbs) +    L[a] += 1 +# print(L) +SUM = 0 +for l in L: +    SUM += l * (l - 1) // 2 +for a in A: +    l = L[a] +    print((SUM - l * (l - 1) // 2 + (l - 1) * (l - 2) // 2))