import sys

input = sys.stdin.readline



from math import factorial

from itertools import combinations

from collections import Counter

from copy import deepcopy

from operator import mul

from functools import reduce



def cmb(n,r):

    r = min(n-r,r)

    if r == 0: return 1

    over = reduce(mul, list(range(n, n - r, -1)))

    under = reduce(mul, list(range(1,r + 1)))

    return over // under



def main():

    n = int(eval(input()))

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

    a_c = Counter(a)

    a_c_sum = 0

    for c in a_c:

        if a_c[c] >= 2:

            a_c_sum += cmb(a_c[c], 2)



    for ea in a:

        if a_c[ea] <= 1:

            sa = 0

        elif a_c[ea] == 2:

            sa = 1

        else:

            sa = cmb(a_c[ea], 2) - cmb(a_c[ea] - 1, 2)

        print((a_c_sum - sa))





if __name__ == '__main__':

    main()

import sys

read = sys.stdin.read

from collections import Counter

def main():

    n = int(eval(input()))

    a = tuple(map(int, input().split()))

    ac = Counter(a)

    com_base = {}

    for i in ac:

        com_base[i] = ac[i] * (ac[i] - 1) / 2

    sum_combase = sum(com_base.values())

    for ae in a:

        r = sum_combase - com_base[ae] + ((ac[ae] - 1) * (ac[ae] - 2) / 2)

        print((int(r)))



if __name__ == '__main__':

    main()
import sys

input = sys.stdin.readline
from math import factorial
from itertools import combinations
from collections import Counter
from copy import deepcopy
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, list(range(n, n - r, -1)))
    under = reduce(mul, list(range(1, r + 1)))
    return over // under


def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    a_c = Counter(a)
    a_c_sum = 0
    for c in a_c:
        if a_c[c] >= 2:
            a_c_sum += cmb(a_c[c], 2)
    for ea in a:
        if a_c[ea] <= 1:
            sa = 0
        elif a_c[ea] == 2:
            sa = 1
        else:
            sa = cmb(a_c[ea], 2) - cmb(a_c[ea] - 1, 2)
        print((a_c_sum - sa))


if __name__ == "__main__":
    main()

import sys

read = sys.stdin.read
from collections import Counter


def main():
    n = int(eval(input()))
    a = tuple(map(int, input().split()))
    ac = Counter(a)
    com_base = {}
    for i in ac:
        com_base[i] = ac[i] * (ac[i] - 1) / 2
    sum_combase = sum(com_base.values())
    for ae in a:
        r = sum_combase - com_base[ae] + ((ac[ae] - 1) * (ac[ae] - 2) / 2)
        print((int(r)))


if __name__ == "__main__":
    main()

-input = sys.stdin.readline -from math import factorial -from itertools import combinations +read = sys.stdin.read -from copy import deepcopy -from operator import mul -from functools import reduce - - -def cmb(n, r): -    r = min(n - r, r) -    if r == 0: -        return 1 -    over = reduce(mul, list(range(n, n - r, -1))) -    under = reduce(mul, list(range(1, r + 1))) -    return over // under -    a = list(map(int, input().split())) -    a_c = Counter(a) -    a_c_sum = 0 -    for c in a_c: -        if a_c[c] >= 2: -            a_c_sum += cmb(a_c[c], 2) -    for ea in a: -        if a_c[ea] <= 1: -            sa = 0 -        elif a_c[ea] == 2: -            sa = 1 -        else: -            sa = cmb(a_c[ea], 2) - cmb(a_c[ea] - 1, 2) -        print((a_c_sum - sa)) +    a = tuple(map(int, input().split())) +    ac = Counter(a) +    com_base = {} +    for i in ac: +        com_base[i] = ac[i] * (ac[i] - 1) / 2 +    sum_combase = sum(com_base.values()) +    for ae in a: +        r = sum_combase - com_base[ae] + ((ac[ae] - 1) * (ac[ae] - 2) / 2) +        print((int(r)))