n = int(eval(input()))

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

b = dict()

c = dict()

d = dict()

for i in range(n):

    if a[i] not in b:

        b[a[i]] = 0

    b[a[i]] += 1

b = list(b.items())

for i in range(len(b)):

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

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

c_sum = sum(list(c.values()))

for i in range(n):

    num = a[i]

    print((c_sum - c[num] + d[num]))



import collections

n = int(eval(input()))

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

c = collections.Counter(a)

c = list(c.items())

num = 0

nc2 = dict()

n_1c2 = dict()

for i in range(len(c)):

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

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

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

for i in range(n):

    tar = a[i]

    print((num-nc2[tar]+n_1c2[tar]))



n = int(eval(input()))
a = list(map(int, input().split()))
b = dict()
c = dict()
d = dict()
for i in range(n):
    if a[i] not in b:
        b[a[i]] = 0
    b[a[i]] += 1
b = list(b.items())
for i in range(len(b)):
    c[b[i][0]] = b[i][1] * (b[i][1] - 1) // 2
    d[b[i][0]] = (b[i][1] - 1) * (b[i][1] - 2) // 2
c_sum = sum(list(c.values()))
for i in range(n):
    num = a[i]
    print((c_sum - c[num] + d[num]))

import collections

n = int(eval(input()))
a = list(map(int, input().split()))
c = collections.Counter(a)
c = list(c.items())
num = 0
nc2 = dict()
n_1c2 = dict()
for i in range(len(c)):
    nc2[c[i][0]] = c[i][1] * (c[i][1] - 1) // 2
    num += c[i][1] * (c[i][1] - 1) // 2
    n_1c2[c[i][0]] = (c[i][1] - 1) * (c[i][1] - 2) // 2
for i in range(n):
    tar = a[i]
    print((num - nc2[tar] + n_1c2[tar]))

+import collections + -b = dict() -c = dict() -d = dict() +c = collections.Counter(a) +c = list(c.items()) +num = 0 +nc2 = dict() +n_1c2 = dict() +for i in range(len(c)): +    nc2[c[i][0]] = c[i][1] * (c[i][1] - 1) // 2 +    num += c[i][1] * (c[i][1] - 1) // 2 +    n_1c2[c[i][0]] = (c[i][1] - 1) * (c[i][1] - 2) // 2 -    if a[i] not in b: -        b[a[i]] = 0 -    b[a[i]] += 1 -b = list(b.items()) -for i in range(len(b)): -    c[b[i][0]] = b[i][1] * (b[i][1] - 1) // 2 -    d[b[i][0]] = (b[i][1] - 1) * (b[i][1] - 2) // 2 -c_sum = sum(list(c.values())) -for i in range(n): -    num = a[i] -    print((c_sum - c[num] + d[num])) +    tar = a[i] +    print((num - nc2[tar] + n_1c2[tar]))