N=int(eval(input()))

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

#print(alist)



dic_a={}

for a in alist:

  if not a in dic_a:

    dic_a[a]=1

  else:

    dic_a[a]+=1

    

all_pair=0

for val in list(dic_a.values()):

  all_pair+=val*(val-1)//2



#print(dic_a,all_pair)

dic_answer={}

for a in alist:

  if a in dic_answer:

    print((dic_answer[a]))

    continue

  

  now=dic_a[a]

  kill=now*(now-1)//2-(now-1)*(now-2)//2

  answer=all_pair-kill

  

  print(answer)

  dic_answer[a]=answer  
N=int(eval(input()))

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

#print(alist)



dic_a={}

for a in alist:

  if not a in dic_a:

    dic_a[a]=1

  else:

    dic_a[a]+=1

    

all_pair=0

for val in list(dic_a.values()):

  all_pair+=val*(val-1)//2



#print(dic_a,all_pair)

for a in alist:

  answer=all_pair-dic_a[a]+1

  print(answer)
N = int(eval(input()))
alist = list(map(int, input().split()))
# print(alist)
dic_a = {}
for a in alist:
    if not a in dic_a:
        dic_a[a] = 1
    else:
        dic_a[a] += 1
all_pair = 0
for val in list(dic_a.values()):
    all_pair += val * (val - 1) // 2
# print(dic_a,all_pair)
dic_answer = {}
for a in alist:
    if a in dic_answer:
        print((dic_answer[a]))
        continue
    now = dic_a[a]
    kill = now * (now - 1) // 2 - (now - 1) * (now - 2) // 2
    answer = all_pair - kill
    print(answer)
    dic_answer[a] = answer

N = int(eval(input()))
alist = list(map(int, input().split()))
# print(alist)
dic_a = {}
for a in alist:
    if not a in dic_a:
        dic_a[a] = 1
    else:
        dic_a[a] += 1
all_pair = 0
for val in list(dic_a.values()):
    all_pair += val * (val - 1) // 2
# print(dic_a,all_pair)
for a in alist:
    answer = all_pair - dic_a[a] + 1
    print(answer)

-dic_answer = {} -    if a in dic_answer: -        print((dic_answer[a])) -        continue -    now = dic_a[a] -    kill = now * (now - 1) // 2 - (now - 1) * (now - 2) // 2 -    answer = all_pair - kill +    answer = all_pair - dic_a[a] + 1 -    dic_answer[a] = answer