from collections import Counter



def Comb(n,k):

    comb_ans=1

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

        comb_ans*=(n-i+1)/i

    comb_ans=int(comb_ans)

    return comb_ans



N=int(eval(input()))

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

C=Counter()

C.update(A)

ans=0

L=[0]*N

for i in range(N):

    L[A[i]-1]+=1

Most=C.most_common()

#print(Most)

for i in range(len(C)):

    ans+=Comb(Most[i][1],2)

for i in range(N):

    pri=ans

    pri=ans-L[A[i]-1]+1

    print(pri)
from collections import Counter



def Comb(n,k):

    comb_ans=1

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

        comb_ans*=(n-i+1)/i

    comb_ans=int(comb_ans)

    return comb_ans



N=int(eval(input()))

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

C=Counter(A)

ans=0

for i in list(C.values()):

    ans+=Comb(i,2)

for i in A:

    print((ans-C[i]+1))
from collections import Counter


def Comb(n, k):
    comb_ans = 1
    for i in range(1, k + 1):
        comb_ans *= (n - i + 1) / i
    comb_ans = int(comb_ans)
    return comb_ans


N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter()
C.update(A)
ans = 0
L = [0] * N
for i in range(N):
    L[A[i] - 1] += 1
Most = C.most_common()
# print(Most)
for i in range(len(C)):
    ans += Comb(Most[i][1], 2)
for i in range(N):
    pri = ans
    pri = ans - L[A[i] - 1] + 1
    print(pri)

from collections import Counter


def Comb(n, k):
    comb_ans = 1
    for i in range(1, k + 1):
        comb_ans *= (n - i + 1) / i
    comb_ans = int(comb_ans)
    return comb_ans


N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
for i in list(C.values()):
    ans += Comb(i, 2)
for i in A:
    print((ans - C[i] + 1))

-C = Counter() -C.update(A) +C = Counter(A) -L = [0] * N -for i in range(N): -    L[A[i] - 1] += 1 -Most = C.most_common() -# print(Most) -for i in range(len(C)): -    ans += Comb(Most[i][1], 2) -for i in range(N): -    pri = ans -    pri = ans - L[A[i] - 1] + 1 -    print(pri) +for i in list(C.values()): +    ans += Comb(i, 2) +for i in A: +    print((ans - C[i] + 1))