import sys

from collections import Counter

readline = sys.stdin.buffer.readline





#二項係数(modなし) O(k)

def large_conbination(n,k): #no mod. return nCk.

    res1 = 1

    for i in range(n,n-k,-1):

        res1*=i

    res2 = 1

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

        res2*= i

    return res1//res2

n = int(readline())

lst1 = list(map(int,readline().split()))

c = Counter(lst1)



ans = 0

dic1 = dict()

for i,j in list(c.items()):

    res1 = large_conbination(j,2)

    res2 = large_conbination(j-1,2)

    ans += res1

    dic1[i] = (res1,res2)



for i in lst1:

    res12 = dic1[i]

    print((ans-res12[0]+res12[1]))
import sys

from collections import defaultdict

readline = sys.stdin.buffer.readline

def even(n): return 1 if n%2==0 else 0

n = int(readline())

lst1 = list(map(int,readline().split()))

dic1 = defaultdict(int)



for i in lst1:

    dic1[i] += 1







al = 0

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

    if i >= 2:

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



for i in lst1:

    res = dic1[i]

    if res >= 2:

        print((al-res*(res-1)//2+(res-1)*(res-2)//2))

    else:

        print(al)
import sys
from collections import Counter

readline = sys.stdin.buffer.readline
# 二項係数(modなし) O(k)
def large_conbination(n, k):  # no mod. return nCk.
    res1 = 1
    for i in range(n, n - k, -1):
        res1 *= i
    res2 = 1
    for i in range(1, k + 1):
        res2 *= i
    return res1 // res2


n = int(readline())
lst1 = list(map(int, readline().split()))
c = Counter(lst1)
ans = 0
dic1 = dict()
for i, j in list(c.items()):
    res1 = large_conbination(j, 2)
    res2 = large_conbination(j - 1, 2)
    ans += res1
    dic1[i] = (res1, res2)
for i in lst1:
    res12 = dic1[i]
    print((ans - res12[0] + res12[1]))

import sys
from collections import defaultdict

readline = sys.stdin.buffer.readline


def even(n):
    return 1 if n % 2 == 0 else 0


n = int(readline())
lst1 = list(map(int, readline().split()))
dic1 = defaultdict(int)
for i in lst1:
    dic1[i] += 1
al = 0
for i in list(dic1.values()):
    if i >= 2:
        al += i * (i - 1) // 2
for i in lst1:
    res = dic1[i]
    if res >= 2:
        print((al - res * (res - 1) // 2 + (res - 1) * (res - 2) // 2))
    else:
        print(al)

-from collections import Counter +from collections import defaultdict -# 二項係数(modなし) O(k) -def large_conbination(n, k):  # no mod. return nCk. -    res1 = 1 -    for i in range(n, n - k, -1): -        res1 *= i -    res2 = 1 -    for i in range(1, k + 1): -        res2 *= i -    return res1 // res2 + + +def even(n): +    return 1 if n % 2 == 0 else 0 -c = Counter(lst1) -ans = 0 -dic1 = dict() -for i, j in list(c.items()): -    res1 = large_conbination(j, 2) -    res2 = large_conbination(j - 1, 2) -    ans += res1 -    dic1[i] = (res1, res2) +dic1 = defaultdict(int) -    res12 = dic1[i] -    print((ans - res12[0] + res12[1])) +    dic1[i] += 1 +al = 0 +for i in list(dic1.values()): +    if i >= 2: +        al += i * (i - 1) // 2 +for i in lst1: +    res = dic1[i] +    if res >= 2: +        print((al - res * (res - 1) // 2 + (res - 1) * (res - 2) // 2)) +    else: +        print(al)