A = eval(input())

B = list(input().split())

import collections

C = collections.Counter(B)

list_after = {}

list_n = list(C.items())

total = 0

for i in list_n:

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

for i in list_n:

    list_after[i[0]] = total - (i[1] * (i[1]-1) / 2 - (i[1]-1) * (i[1]-2) / 2)

for i in B:

    print((int(list_after[i])))
A = int(eval(input()))

import collections

total = 0

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

dic = collections.Counter(listN)

listB = list(dic.values())

for i in listB:

    total += i * (i-1) // 2

dic_keys = list(dic.keys())

dic_values = list(dic.values())

for i in range(len(dic_values)):

    B = dic_values[i]

    dic_values[i] = total-(B-1)

dic = {}

for i in range(len(dic_values)):

    dic[dic_keys[i]] = dic_values[i]

for i in listN:

    print((dic[i]))
A = eval(input())
B = list(input().split())
import collections

C = collections.Counter(B)
list_after = {}
list_n = list(C.items())
total = 0
for i in list_n:
    total += i[1] * (i[1] - 1) / 2
for i in list_n:
    list_after[i[0]] = total - (i[1] * (i[1] - 1) / 2 - (i[1] - 1) * (i[1] - 2) / 2)
for i in B:
    print((int(list_after[i])))

A = int(eval(input()))
import collections

total = 0
listN = list(map(int, input().split()))
dic = collections.Counter(listN)
listB = list(dic.values())
for i in listB:
    total += i * (i - 1) // 2
dic_keys = list(dic.keys())
dic_values = list(dic.values())
for i in range(len(dic_values)):
    B = dic_values[i]
    dic_values[i] = total - (B - 1)
dic = {}
for i in range(len(dic_values)):
    dic[dic_keys[i]] = dic_values[i]
for i in listN:
    print((dic[i]))

-A = eval(input()) -B = list(input().split()) +A = int(eval(input())) -C = collections.Counter(B) -list_after = {} -list_n = list(C.items()) -for i in list_n: -    total += i[1] * (i[1] - 1) / 2 -for i in list_n: -    list_after[i[0]] = total - (i[1] * (i[1] - 1) / 2 - (i[1] - 1) * (i[1] - 2) / 2) -for i in B: -    print((int(list_after[i]))) +listN = list(map(int, input().split())) +dic = collections.Counter(listN) +listB = list(dic.values()) +for i in listB: +    total += i * (i - 1) // 2 +dic_keys = list(dic.keys()) +dic_values = list(dic.values()) +for i in range(len(dic_values)): +    B = dic_values[i] +    dic_values[i] = total - (B - 1) +dic = {} +for i in range(len(dic_values)): +    dic[dic_keys[i]] = dic_values[i] +for i in listN: +    print((dic[i]))