from collections import defaultdict

n, *D  = [list(map(int, s.split())) for s in open(0)]

D = D[0]

dic = defaultdict(int)

for i in D:

    dic[i] += 1



total_comb = 0

for j in dic:

    if dic[j] >= 2:

        total_comb += dic[j] * (dic[j] - 1) / 2

for k in D:

    if dic[k] >= 2:

        print((int(total_comb - dic[k] + 1)))

    else:

        print((int(total_comb)))
from collections import defaultdict





def main():

    d = defaultdict(int)

    nums = []

    _ = eval(input())

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

    for n in nums:

        d[n] += 1

    

    total_combs = 0

    for k in list(d.keys()):

        total_combs += int((d[k]*(d[k]-1))/2)

    

    for n in nums:

        print((total_combs - (d[n] - 1)))

        

 

if __name__ == "__main__":

    main()
from collections import defaultdict

n, *D = [list(map(int, s.split())) for s in open(0)]
D = D[0]
dic = defaultdict(int)
for i in D:
    dic[i] += 1
total_comb = 0
for j in dic:
    if dic[j] >= 2:
        total_comb += dic[j] * (dic[j] - 1) / 2
for k in D:
    if dic[k] >= 2:
        print((int(total_comb - dic[k] + 1)))
    else:
        print((int(total_comb)))

from collections import defaultdict


def main():
    d = defaultdict(int)
    nums = []
    _ = eval(input())
    nums = list(map(int, input().split()))
    for n in nums:
        d[n] += 1
    total_combs = 0
    for k in list(d.keys()):
        total_combs += int((d[k] * (d[k] - 1)) / 2)
    for n in nums:
        print((total_combs - (d[n] - 1)))


if __name__ == "__main__":
    main()

-n, *D = [list(map(int, s.split())) for s in open(0)] -D = D[0] -dic = defaultdict(int) -for i in D: -    dic[i] += 1 -total_comb = 0 -for j in dic: -    if dic[j] >= 2: -        total_comb += dic[j] * (dic[j] - 1) / 2 -for k in D: -    if dic[k] >= 2: -        print((int(total_comb - dic[k] + 1))) -    else: -        print((int(total_comb))) + +def main(): +    d = defaultdict(int) +    nums = [] +    _ = eval(input()) +    nums = list(map(int, input().split())) +    for n in nums: +        d[n] += 1 +    total_combs = 0 +    for k in list(d.keys()): +        total_combs += int((d[k] * (d[k] - 1)) / 2) +    for n in nums: +        print((total_combs - (d[n] - 1))) + + +if __name__ == "__main__": +    main()