from collections import Counter



N = int(eval(input()))

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

countdic = Counter(A)

goukei = 0

ans = ''

for key,value in list(countdic.items()):

    goukei += (value*(value-1))//2

for i in A:

    ans = goukei -(countdic[i]*(countdic[i]-1))//2 + ((countdic[i]-1)*(countdic[i]-2))//2

    print(ans)
from collections import Counter

import sys



def input():

    return sys.stdin.readline().strip()

def combi(num):

    return num * (num - 1) // 2

def main():

    N = int(eval(input()))

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

    counterdic = Counter(A)

    ma = 0

    for value in list(counterdic.values()):

        ma += combi(value)

    for i in A:

        print((ma-combi(counterdic[i])+combi(counterdic[i]-1)))

if __name__ == "__main__":

    main()
from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
countdic = Counter(A)
goukei = 0
ans = ""
for key, value in list(countdic.items()):
    goukei += (value * (value - 1)) // 2
for i in A:
    ans = (
        goukei
        - (countdic[i] * (countdic[i] - 1)) // 2
        + ((countdic[i] - 1) * (countdic[i] - 2)) // 2
    )
    print(ans)

from collections import Counter
import sys


def input():
    return sys.stdin.readline().strip()


def combi(num):
    return num * (num - 1) // 2


def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    counterdic = Counter(A)
    ma = 0
    for value in list(counterdic.values()):
        ma += combi(value)
    for i in A:
        print((ma - combi(counterdic[i]) + combi(counterdic[i] - 1)))


if __name__ == "__main__":
    main()

+import sys -N = int(eval(input())) -A = list(map(int, input().split())) -countdic = Counter(A) -goukei = 0 -ans = "" -for key, value in list(countdic.items()): -    goukei += (value * (value - 1)) // 2 -for i in A: -    ans = ( -        goukei -        - (countdic[i] * (countdic[i] - 1)) // 2 -        + ((countdic[i] - 1) * (countdic[i] - 2)) // 2 -    ) -    print(ans) + +def input(): +    return sys.stdin.readline().strip() + + +def combi(num): +    return num * (num - 1) // 2 + + +def main(): +    N = int(eval(input())) +    A = list(map(int, input().split())) +    counterdic = Counter(A) +    ma = 0 +    for value in list(counterdic.values()): +        ma += combi(value) +    for i in A: +        print((ma - combi(counterdic[i]) + combi(counterdic[i] - 1))) + + +if __name__ == "__main__": +    main()