from collections import Counter

N = int(eval(input()))

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

c = Counter(A)



def fac2(n):

    if n < 2:

        return 0

    ans = n * (n-1) // 2

    return ans



d = {key:fac2(val) for key, val in list(c.items())}

sum_val = sum(d.values())

for a in A:

    ans = sum_val - d[a] + fac2(c[a]-1)

    print(ans)
from collections import Counter

N = int(input())

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

c = Counter(A)

d = {}



def fac2(n):

    if n < 2:

        return 0

    ans = n * (n-1) // 2

    return ans



for key, val in c.items():

    d[key] = fac2(val)



d = {key:fac2(val) for key, val in c.items()}

sum_val = sum(d.values())

ans = [sum_val - d[a] + fac2(c[a]-1) for a in A]

print(*ans, sep="\n")

from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
c = Counter(A)


def fac2(n):
    if n < 2:
        return 0
    ans = n * (n - 1) // 2
    return ans


d = {key: fac2(val) for key, val in list(c.items())}
sum_val = sum(d.values())
for a in A:
    ans = sum_val - d[a] + fac2(c[a] - 1)
    print(ans)

from collections import Counter

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
d = {}


def fac2(n):
    if n < 2:
        return 0
    ans = n * (n - 1) // 2
    return ans


for key, val in c.items():
    d[key] = fac2(val)
d = {key: fac2(val) for key, val in c.items()}
sum_val = sum(d.values())
ans = [sum_val - d[a] + fac2(c[a] - 1) for a in A]
print(*ans, sep="\n")

-N = int(eval(input())) +N = int(input()) +d = {} -d = {key: fac2(val) for key, val in list(c.items())} +for key, val in c.items(): +    d[key] = fac2(val) +d = {key: fac2(val) for key, val in c.items()} -for a in A: -    ans = sum_val - d[a] + fac2(c[a] - 1) -    print(ans) +ans = [sum_val - d[a] + fac2(c[a] - 1) for a in A] +print(*ans, sep="\n")