import collections

n = int(eval(input()))

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

c = collections.Counter(a)

s = 0

for i in set(a):

    s += c[i] * (c[i] - 1)

for i in a:

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

n = int(eval(input()))

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

c = Counter(a)

s = 0

for i in set(a):

    s += c[i] * (c[i] - 1)

dp = [-1] * (n + 1)

for i in a:

    if dp[i] == -1:

        dp[i] = (s - c[i] * (c[i] - 1) + (c[i] - 1) * (c[i] - 2)) // 2

        print((dp[i]))

    else:

        print((dp[i]))

import collections

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

from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
c = Counter(a)
s = 0
for i in set(a):
    s += c[i] * (c[i] - 1)
dp = [-1] * (n + 1)
for i in a:
    if dp[i] == -1:
        dp[i] = (s - c[i] * (c[i] - 1) + (c[i] - 1) * (c[i] - 2)) // 2
        print((dp[i]))
    else:
        print((dp[i]))

-import collections +from collections import Counter -c = collections.Counter(a) +c = Counter(a) +dp = [-1] * (n + 1) -    print((int((s - (c[i] * (c[i] - 1)) + ((c[i] - 1) * (c[i] - 2))) / 2))) +    if dp[i] == -1: +        dp[i] = (s - c[i] * (c[i] - 1) + (c[i] - 1) * (c[i] - 2)) // 2 +        print((dp[i])) +    else: +        print((dp[i]))