import collections

MOD = 10**18+9

n = int(eval(input()))

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

b = [[0 for j in range(2)] for i in range(n)]

c = collections.Counter(a)

s = 0

def nCr(nn, r, mod):

	r = min(r, nn-r)

	numer = denom = 1

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

		numer = numer * (nn+1-i) % mod

		denom = denom * i % mod

	return numer * pow(denom, mod-2, mod) % mod

for i in c:

	if c[i] < 2:

		b[i-1][0] = 0

	else:

		b[i-1][0] = nCr(c[i],2,MOD)

		s += b[i-1][0]

	if c[i]-1 < 2:

		b[i-1][1] = 0

	else:

		b[i-1][1] = nCr(c[i]-1,2,MOD)

for i in a:

	ans = s-b[i-1][0] + b[i-1][1]

	print (ans)
import collections

n = int(eval(input()))

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

b = [[0 for j in range(2)] for i in range(n)]

c = collections.Counter(a)

s = 0

for i in c:

	b[i-1][0] = c[i]*(c[i]-1)//2

	s += b[i-1][0]

	b[i-1][1] = (c[i]-1)*(c[i]-2)//2

for i in a:

	ans = s-b[i-1][0] + b[i-1][1]

	print (ans)
import collections

MOD = 10**18 + 9
n = int(eval(input()))
a = list(map(int, input().split()))
b = [[0 for j in range(2)] for i in range(n)]
c = collections.Counter(a)
s = 0


def nCr(nn, r, mod):
    r = min(r, nn - r)
    numer = denom = 1
    for i in range(1, r + 1):
        numer = numer * (nn + 1 - i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod - 2, mod) % mod


for i in c:
    if c[i] < 2:
        b[i - 1][0] = 0
    else:
        b[i - 1][0] = nCr(c[i], 2, MOD)
        s += b[i - 1][0]
    if c[i] - 1 < 2:
        b[i - 1][1] = 0
    else:
        b[i - 1][1] = nCr(c[i] - 1, 2, MOD)
for i in a:
    ans = s - b[i - 1][0] + b[i - 1][1]
    print(ans)

import collections

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

-MOD = 10**18 + 9 - - -def nCr(nn, r, mod): -    r = min(r, nn - r) -    numer = denom = 1 -    for i in range(1, r + 1): -        numer = numer * (nn + 1 - i) % mod -        denom = denom * i % mod -    return numer * pow(denom, mod - 2, mod) % mod - - -    if c[i] < 2: -        b[i - 1][0] = 0 -    else: -        b[i - 1][0] = nCr(c[i], 2, MOD) -        s += b[i - 1][0] -    if c[i] - 1 < 2: -        b[i - 1][1] = 0 -    else: -        b[i - 1][1] = nCr(c[i] - 1, 2, MOD) +    b[i - 1][0] = c[i] * (c[i] - 1) // 2 +    s += b[i - 1][0] +    b[i - 1][1] = (c[i] - 1) * (c[i] - 2) // 2