n=int(eval(input()))

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

sa=sorted(a)

count=1

k=[0]*(n+2)

for i in range(n-1):

  if sa[i+1]==sa[i]:

    count+=1

  else:

    k[sa[i]]=count

    count=1

k[sa[-1]]=count

ans=0

for i in range(len(k)):

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

for i in a:

  print((int(ans-(k[i]*(k[i]-1)/2)+((k[i]-1)*(k[i]-2)/2))))
from collections import Counter



n= int(eval(input()))

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

ca = Counter(a)

sa = set(a)

sum_ans=0

for i in sa:

  sum_ans+=(ca[i]*(ca[i]-1))//2



for i in a:

  print((sum_ans-(ca[i]*(ca[i]-1))//2+((ca[i]-1)*(ca[i]-2))//2))
n = int(eval(input()))
a = list(map(int, input().split()))
sa = sorted(a)
count = 1
k = [0] * (n + 2)
for i in range(n - 1):
    if sa[i + 1] == sa[i]:
        count += 1
    else:
        k[sa[i]] = count
        count = 1
k[sa[-1]] = count
ans = 0
for i in range(len(k)):
    ans += k[i] * (k[i] - 1) / 2
for i in a:
    print((int(ans - (k[i] * (k[i] - 1) / 2) + ((k[i] - 1) * (k[i] - 2) / 2))))

from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
ca = Counter(a)
sa = set(a)
sum_ans = 0
for i in sa:
    sum_ans += (ca[i] * (ca[i] - 1)) // 2
for i in a:
    print((sum_ans - (ca[i] * (ca[i] - 1)) // 2 + ((ca[i] - 1) * (ca[i] - 2)) // 2))

+from collections import Counter + -sa = sorted(a) -count = 1 -k = [0] * (n + 2) -for i in range(n - 1): -    if sa[i + 1] == sa[i]: -        count += 1 -    else: -        k[sa[i]] = count -        count = 1 -k[sa[-1]] = count -ans = 0 -for i in range(len(k)): -    ans += k[i] * (k[i] - 1) / 2 +ca = Counter(a) +sa = set(a) +sum_ans = 0 +for i in sa: +    sum_ans += (ca[i] * (ca[i] - 1)) // 2 -    print((int(ans - (k[i] * (k[i] - 1) / 2) + ((k[i] - 1) * (k[i] - 2) / 2)))) +    print((sum_ans - (ca[i] * (ca[i] - 1)) // 2 + ((ca[i] - 1) * (ca[i] - 2)) // 2))