n = int(input())

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

conbi = [0]*n

for i in balls:

    conbi[i-1] +=1

result = 0

for j in range(n):

    result += (conbi[j]*(conbi[j]-1))//2

for k in balls:

    print(result-conbi[k-1]+1, end=" ")

def solve():

    N = int(eval(input()))

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

    conb = [0]*N

    ans = 0

    for i in A:

        conb[i-1] += 1

    for j in conb:

        if j != 0:

            ans += j*(j-1)//2

    for k in range(N):

        print((ans- conb[A[k]-1]+1))







if __name__ == '__main__':

    solve()
n = int(input())
balls = list(map(int, input().split()))
conbi = [0] * n
for i in balls:
    conbi[i - 1] += 1
result = 0
for j in range(n):
    result += (conbi[j] * (conbi[j] - 1)) // 2
for k in balls:
    print(result - conbi[k - 1] + 1, end=" ")

def solve():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    conb = [0] * N
    ans = 0
    for i in A:
        conb[i - 1] += 1
    for j in conb:
        if j != 0:
            ans += j * (j - 1) // 2
    for k in range(N):
        print((ans - conb[A[k] - 1] + 1))


if __name__ == "__main__":
    solve()

-n = int(input()) -balls = list(map(int, input().split())) -conbi = [0] * n -for i in balls: -    conbi[i - 1] += 1 -result = 0 -for j in range(n): -    result += (conbi[j] * (conbi[j] - 1)) // 2 -for k in balls: -    print(result - conbi[k - 1] + 1, end=" ") +def solve(): +    N = int(eval(input())) +    A = list(map(int, input().split())) +    conb = [0] * N +    ans = 0 +    for i in A: +        conb[i - 1] += 1 +    for j in conb: +        if j != 0: +            ans += j * (j - 1) // 2 +    for k in range(N): +        print((ans - conb[A[k] - 1] + 1)) + + +if __name__ == "__main__": +    solve()