from math import factorial





def c(n):

    if n < 2:

        return 0

    return factorial(n) // (factorial(n-2) * factorial(2))





def main():

    N = int(eval(input()))  # 文字列または整数(一変数)

    a = list(map(int, input().split()))  # 整数のリスト

    for i in range(N):

        a[i] -= 1



    nums = [0 for _ in range(N)]



    for i in a:

        nums[i] += 1



    b = [c(nums[i]) for i in range(N)]

    sum_b = sum(b)



    b_alt = [c(nums[i]-1) for i in range(N)]



    for i in range(N):

        print((sum_b - b[a[i]] + b_alt[a[i]]))





if __name__ == '__main__':

    main()

def main():

    N = int(eval(input()))

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



    # print(N)

    # print(A)

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

    d2 = {}

    d3 = {}

    # print(d)

    # return





    for i in A:

        d[i] += 1



    # print(d)

    sum = 0

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

        d2[i] = int(d[i] * (d[i]-1) / 2)

        sum += d2[i]



    # print(d2)



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

        if d[i] == 0: d3[i] = 0

        else: d3[i] = int((d[i]-1) * (d[i]-2) / 2)



    # print(d3)





    for i in A:

        print((sum - d2[i] + d3[i]))



if __name__ == '__main__':

    main()

from math import factorial


def c(n):
    if n < 2:
        return 0
    return factorial(n) // (factorial(n - 2) * factorial(2))


def main():
    N = int(eval(input()))  # 文字列または整数(一変数)
    a = list(map(int, input().split()))  # 整数のリスト
    for i in range(N):
        a[i] -= 1
    nums = [0 for _ in range(N)]
    for i in a:
        nums[i] += 1
    b = [c(nums[i]) for i in range(N)]
    sum_b = sum(b)
    b_alt = [c(nums[i] - 1) for i in range(N)]
    for i in range(N):
        print((sum_b - b[a[i]] + b_alt[a[i]]))


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    # print(N)
    # print(A)
    d = {i: 0 for i in range(1, N + 1)}
    d2 = {}
    d3 = {}
    # print(d)
    # return
    for i in A:
        d[i] += 1
    # print(d)
    sum = 0
    for i in range(1, N + 1):
        d2[i] = int(d[i] * (d[i] - 1) / 2)
        sum += d2[i]
    # print(d2)
    for i in range(1, N + 1):
        if d[i] == 0:
            d3[i] = 0
        else:
            d3[i] = int((d[i] - 1) * (d[i] - 2) / 2)
    # print(d3)
    for i in A:
        print((sum - d2[i] + d3[i]))


if __name__ == "__main__":
    main()

-from math import factorial - - -def c(n): -    if n < 2: -        return 0 -    return factorial(n) // (factorial(n - 2) * factorial(2)) - - -    N = int(eval(input()))  # 文字列または整数(一変数) -    a = list(map(int, input().split()))  # 整数のリスト -    for i in range(N): -        a[i] -= 1 -    nums = [0 for _ in range(N)] -    for i in a: -        nums[i] += 1 -    b = [c(nums[i]) for i in range(N)] -    sum_b = sum(b) -    b_alt = [c(nums[i] - 1) for i in range(N)] -    for i in range(N): -        print((sum_b - b[a[i]] + b_alt[a[i]])) +    N = int(eval(input())) +    A = list(map(int, input().split())) +    # print(N) +    # print(A) +    d = {i: 0 for i in range(1, N + 1)} +    d2 = {} +    d3 = {} +    # print(d) +    # return +    for i in A: +        d[i] += 1 +    # print(d) +    sum = 0 +    for i in range(1, N + 1): +        d2[i] = int(d[i] * (d[i] - 1) / 2) +        sum += d2[i] +    # print(d2) +    for i in range(1, N + 1): +        if d[i] == 0: +            d3[i] = 0 +        else: +            d3[i] = int((d[i] - 1) * (d[i] - 2) / 2) +    # print(d3) +    for i in A: +        print((sum - d2[i] + d3[i]))