from collections import defaultdict



N = int(eval(input()))

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



counter = defaultdict(list)

for i in range(len(nums)):

  counter[nums[i]].append(i)



total = 0

for _,v in list(counter.items()):

  v = len(v)

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



for k in range(len(nums)):

  print((total - (len(counter[nums[k]])-1)))
from collections import defaultdict



N = int(eval(input()))

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



counter = defaultdict(list)

for i in range(len(nums)):

  counter[nums[i]].append(i)



total = 0

for _,v in list(counter.items()):

  v = len(v)

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



for k in range(len(nums)):

  t = len(counter[nums[k]])

  print((total - t*(t-1)//2 + (t-1)*(t-2)//2))
from collections import defaultdict

N = int(eval(input()))
nums = list(map(int, input().split()))
counter = defaultdict(list)
for i in range(len(nums)):
    counter[nums[i]].append(i)
total = 0
for _, v in list(counter.items()):
    v = len(v)
    total += (v * (v - 1)) // 2
for k in range(len(nums)):
    print((total - (len(counter[nums[k]]) - 1)))

from collections import defaultdict

N = int(eval(input()))
nums = list(map(int, input().split()))
counter = defaultdict(list)
for i in range(len(nums)):
    counter[nums[i]].append(i)
total = 0
for _, v in list(counter.items()):
    v = len(v)
    total += (v * (v - 1)) // 2
for k in range(len(nums)):
    t = len(counter[nums[k]])
    print((total - t * (t - 1) // 2 + (t - 1) * (t - 2) // 2))

-    print((total - (len(counter[nums[k]]) - 1))) +    t = len(counter[nums[k]]) +    print((total - t * (t - 1) // 2 + (t - 1) * (t - 2) // 2))