N=int(eval(input()))

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

dic={}

for a in A:

  if a in dic:

    dic[a]+=1

  else:

    dic[a]=1

   



c=0

for i in list(dic.values()):

  c+=i*(i-1)/2

for j in range(1,N+1):

  d=c-dic[A[j-1]]+1

  print((int(d)))

  

n=int(eval(input()))

cnt=[0]*(n+1)

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

for i in range(n):

  cnt[a[i]]+=1 

ans=0  

for i in range(1,n+1):

  if cnt[i]>=1:

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

for i in range(n):

  print((ans-cnt[a[i]]+1))

  
N = int(eval(input()))
A = list(map(int, input().split()))
dic = {}
for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1
c = 0
for i in list(dic.values()):
    c += i * (i - 1) / 2
for j in range(1, N + 1):
    d = c - dic[A[j - 1]] + 1
    print((int(d)))

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

-N = int(eval(input())) -A = list(map(int, input().split())) -dic = {} -for a in A: -    if a in dic: -        dic[a] += 1 -    else: -        dic[a] = 1 -c = 0 -for i in list(dic.values()): -    c += i * (i - 1) / 2 -for j in range(1, N + 1): -    d = c - dic[A[j - 1]] + 1 -    print((int(d))) +n = int(eval(input())) +cnt = [0] * (n + 1) +a = list(map(int, input().split())) +for i in range(n): +    cnt[a[i]] += 1 +ans = 0 +for i in range(1, n + 1): +    if cnt[i] >= 1: +        ans += cnt[i] * (cnt[i] - 1) // 2 +for i in range(n): +    print((ans - cnt[a[i]] + 1))