import bisect



N = int(eval(input()))

A = [int(x) for x in input().split()]



B = sorted(A)

cnt = [0] * (N+1)

for k in range(1, N+1):

    cnt[k] = bisect.bisect_left(B, k+1)

for k in range(N):

    cnt[-1-k] -= cnt[-2-k]



ALL = 0

for i in range(1, N+1):

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



for k in range(N):

    ans = ALL - cnt[A[k]]*(cnt[A[k]]-1)//2 + (cnt[A[k]]-1)*((cnt[A[k]]-1)-1)//2

    print(ans)
N = int(eval(input()))

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



cnt = [0] * (N+1)

for i in range(N):

    cnt[A[i]] += 1



nsum = [cnt[n]*(cnt[n]-1)//2 for n in range(N+1)]

SUM = sum(nsum)



for k in range(N):

    kadd = cnt[A[k]] - 1

    print((SUM - nsum[A[k]] + kadd*(kadd-1)//2))
import bisect

N = int(eval(input()))
A = [int(x) for x in input().split()]
B = sorted(A)
cnt = [0] * (N + 1)
for k in range(1, N + 1):
    cnt[k] = bisect.bisect_left(B, k + 1)
for k in range(N):
    cnt[-1 - k] -= cnt[-2 - k]
ALL = 0
for i in range(1, N + 1):
    ALL += cnt[i] * (cnt[i] - 1) // 2
for k in range(N):
    ans = (
        ALL
        - cnt[A[k]] * (cnt[A[k]] - 1) // 2
        + (cnt[A[k]] - 1) * ((cnt[A[k]] - 1) - 1) // 2
    )
    print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
cnt = [0] * (N + 1)
for i in range(N):
    cnt[A[i]] += 1
nsum = [cnt[n] * (cnt[n] - 1) // 2 for n in range(N + 1)]
SUM = sum(nsum)
for k in range(N):
    kadd = cnt[A[k]] - 1
    print((SUM - nsum[A[k]] + kadd * (kadd - 1) // 2))

-import bisect - -A = [int(x) for x in input().split()] -B = sorted(A) +A = list(map(int, input().split())) -for k in range(1, N + 1): -    cnt[k] = bisect.bisect_left(B, k + 1) +for i in range(N): +    cnt[A[i]] += 1 +nsum = [cnt[n] * (cnt[n] - 1) // 2 for n in range(N + 1)] +SUM = sum(nsum) -    cnt[-1 - k] -= cnt[-2 - k] -ALL = 0 -for i in range(1, N + 1): -    ALL += cnt[i] * (cnt[i] - 1) // 2 -for k in range(N): -    ans = ( -        ALL -        - cnt[A[k]] * (cnt[A[k]] - 1) // 2 -        + (cnt[A[k]] - 1) * ((cnt[A[k]] - 1) - 1) // 2 -    ) -    print(ans) +    kadd = cnt[A[k]] - 1 +    print((SUM - nsum[A[k]] + kadd * (kadd - 1) // 2))