N = int(input())

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



di = {}

B = set(A)

for b in B:

  di[b] = 0

total = 0

for a in A:

  di[a]+=1

for v in di.values():

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

#print(di.values(),total)

ans = []

for a in A:

  ans.append(total-di[a]+1)

print(*ans,sep='\n')

from collections import Counter

def solve():

  N = int(input())

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

  c = Counter(A)

  cnt = 0

  for k,v in c.items():

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

  ans = [cnt]*N

  for i in range(N):

    ans[i] -= c[A[i]]*(c[A[i]]-1)//2

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

  

  return ans

print(*solve(),sep='\n')

N = int(input())
A = list(map(int, input().split()))
di = {}
B = set(A)
for b in B:
    di[b] = 0
total = 0
for a in A:
    di[a] += 1
for v in di.values():
    total += v * (v - 1) // 2
# print(di.values(),total)
ans = []
for a in A:
    ans.append(total - di[a] + 1)
print(*ans, sep="\n")

from collections import Counter


def solve():
    N = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    cnt = 0
    for k, v in c.items():
        cnt += v * (v - 1) // 2
    ans = [cnt] * N
    for i in range(N):
        ans[i] -= c[A[i]] * (c[A[i]] - 1) // 2
        ans[i] += (c[A[i]] - 1) * (c[A[i]] - 2) // 2
    return ans


print(*solve(), sep="\n")

-N = int(input()) -A = list(map(int, input().split())) -di = {} -B = set(A) -for b in B: -    di[b] = 0 -total = 0 -for a in A: -    di[a] += 1 -for v in di.values(): -    total += v * (v - 1) // 2 -# print(di.values(),total) -ans = [] -for a in A: -    ans.append(total - di[a] + 1) -print(*ans, sep="\n") +from collections import Counter + + +def solve(): +    N = int(input()) +    A = list(map(int, input().split())) +    c = Counter(A) +    cnt = 0 +    for k, v in c.items(): +        cnt += v * (v - 1) // 2 +    ans = [cnt] * N +    for i in range(N): +        ans[i] -= c[A[i]] * (c[A[i]] - 1) // 2 +        ans[i] += (c[A[i]] - 1) * (c[A[i]] - 2) // 2 +    return ans + + +print(*solve(), sep="\n")