N = int(eval(input()))

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

C = {}

for i in range(N):

    if A[i] not in C:

        C[A[i]] = 0

    C[A[i]] += 1

K = 0

for j in C:

    K += (C[j]*(C[j]-1))//2

for k in range(N):

    j = A[k]

    print((K-C[j]+1))
N = int(eval(input()))

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

A.insert(0,0)

C = {i:0 for i in range(1,N+1)}

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

    C[A[i]] += 1

tot = 0

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

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

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

    c = C[A[i]]-1

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

    print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
C = {}
for i in range(N):
    if A[i] not in C:
        C[A[i]] = 0
    C[A[i]] += 1
K = 0
for j in C:
    K += (C[j] * (C[j] - 1)) // 2
for k in range(N):
    j = A[k]
    print((K - C[j] + 1))

N = int(eval(input()))
A = list(map(int, input().split()))
A.insert(0, 0)
C = {i: 0 for i in range(1, N + 1)}
for i in range(1, N + 1):
    C[A[i]] += 1
tot = 0
for i in range(1, N + 1):
    tot += (C[i] * (C[i] - 1)) // 2
for i in range(1, N + 1):
    c = C[A[i]] - 1
    ans = tot - (C[A[i]] * (C[A[i]] - 1)) // 2 + (c * (c - 1)) // 2
    print(ans)

-C = {} -for i in range(N): -    if A[i] not in C: -        C[A[i]] = 0 +A.insert(0, 0) +C = {i: 0 for i in range(1, N + 1)} +for i in range(1, N + 1): -K = 0 -for j in C: -    K += (C[j] * (C[j] - 1)) // 2 -for k in range(N): -    j = A[k] -    print((K - C[j] + 1)) +tot = 0 +for i in range(1, N + 1): +    tot += (C[i] * (C[i] - 1)) // 2 +for i in range(1, N + 1): +    c = C[A[i]] - 1 +    ans = tot - (C[A[i]] * (C[A[i]] - 1)) // 2 + (c * (c - 1)) // 2 +    print(ans)