'''

import numpy as np

N = int(input())

A = np.array(list(map(int, input().split(' '))))

num_sum = 0

remove_array = np.array([], int)

for i in range(N):

    c1 = np.count_nonzero(A == i + 1)

    c2 = np.count_nonzero(A == A[i])

    if c2 <= 1:

        remove_array = np.append(remove_array, 0)

    else:

        remove_array = np.append(remove_array, c2 - 1)

    num_sum += int(c1 * (c1 - 1) / 2)

print(*(num_sum - remove_array), sep='\n')

'''

import collections

N = int(eval(input()))

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

cnt = collections.Counter(A)

total = 0

for key in list(cnt.keys()):

    total += cnt[key] * (cnt[key] - 1) // 2

for i in range(N):

    tmp = total

    tmp -= cnt[A[i]] * (cnt[A[i]] - 1) // 2

    tmp += (cnt[A[i]] - 1) * (cnt[A[i]] - 2) // 2

    print(tmp)
'''

import numpy as np

N = int(input())

A = np.array(list(map(int, input().split(' '))))

num_sum = 0

remove_array = np.array([], int)

for i in range(N):

    c1 = np.count_nonzero(A == i + 1)

    c2 = np.count_nonzero(A == A[i])

    if c2 <= 1:

        remove_array = np.append(remove_array, 0) ←　appendがネックになってる？

    else:

        remove_array = np.append(remove_array, c2 - 1)

    num_sum += int(c1 * (c1 - 1) / 2)

print(*(num_sum - remove_array), sep='\n')

'''

import collections

N = int(eval(input()))

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

cnt = collections.Counter(A) # リストやイテレータから値の出現回数をカウントできる（出力は辞書型）

total = 0

for key in list(cnt.keys()):

    total += cnt[key] * (cnt[key] - 1) // 2

for i in range(N):

    tmp = total

    print((tmp - (cnt[A[i]] - 1)))

#    tmp -= cnt[A[i]] * (cnt[A[i]] - 1) // 2

#    tmp += (cnt[A[i]] - 1) * (cnt[A[i]] - 2) // 2
"""
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split(' '))))
num_sum = 0
remove_array = np.array([], int)
for i in range(N):
    c1 = np.count_nonzero(A == i + 1)
    c2 = np.count_nonzero(A == A[i])
    if c2 <= 1:
        remove_array = np.append(remove_array, 0)
    else:
        remove_array = np.append(remove_array, c2 - 1)
    num_sum += int(c1 * (c1 - 1) / 2)
print(*(num_sum - remove_array), sep='\n')
"""
import collections

N = int(eval(input()))
A = list(map(int, input().split()))
cnt = collections.Counter(A)
total = 0
for key in list(cnt.keys()):
    total += cnt[key] * (cnt[key] - 1) // 2
for i in range(N):
    tmp = total
    tmp -= cnt[A[i]] * (cnt[A[i]] - 1) // 2
    tmp += (cnt[A[i]] - 1) * (cnt[A[i]] - 2) // 2
    print(tmp)

"""
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split(' '))))
num_sum = 0
remove_array = np.array([], int)
for i in range(N):
    c1 = np.count_nonzero(A == i + 1)
    c2 = np.count_nonzero(A == A[i])
    if c2 <= 1:
        remove_array = np.append(remove_array, 0) ←　appendがネックになってる？
    else:
        remove_array = np.append(remove_array, c2 - 1)
    num_sum += int(c1 * (c1 - 1) / 2)
print(*(num_sum - remove_array), sep='\n')
"""
import collections

N = int(eval(input()))
A = list(map(int, input().split()))
cnt = collections.Counter(A)  # リストやイテレータから値の出現回数をカウントできる（出力は辞書型）
total = 0
for key in list(cnt.keys()):
    total += cnt[key] * (cnt[key] - 1) // 2
for i in range(N):
    tmp = total
    print((tmp - (cnt[A[i]] - 1)))
#    tmp -= cnt[A[i]] * (cnt[A[i]] - 1) // 2
#    tmp += (cnt[A[i]] - 1) * (cnt[A[i]] - 2) // 2

-        remove_array = np.append(remove_array, 0) +        remove_array = np.append(remove_array, 0) ←　appendがネックになってる？ -cnt = collections.Counter(A) +cnt = collections.Counter(A)  # リストやイテレータから値の出現回数をカウントできる（出力は辞書型） -    tmp -= cnt[A[i]] * (cnt[A[i]] - 1) // 2 -    tmp += (cnt[A[i]] - 1) * (cnt[A[i]] - 2) // 2 -    print(tmp) +    print((tmp - (cnt[A[i]] - 1))) +#    tmp -= cnt[A[i]] * (cnt[A[i]] - 1) // 2 +#    tmp += (cnt[A[i]] - 1) * (cnt[A[i]] - 2) // 2