# coding: utf-8

# Your code here!

# coding: utf-8

import sys

sys.setrecursionlimit(10000000)



#const

dxdy=((1,0),(0,1))

# my functions here!

def pin(type=int):

    return list(map(type,input().rstrip().split()))



def resolve():

    N,=pin()

    A=list(pin())

    from collections import Counter as ct

    a=ct(A)

    t=(list(a.items()))

    #print(t)

    

    Sum=0

    for l in list(a.values()):

        Sum+=(l*(l-1))//2 

    ans=[0]*N

    for j in list(a.items()):

        x,y=j

        ans[x-1]=Sum-((y*(y-1))//2)+(((y-2)*(y-1))//2)     

    for i in A:

        print((ans[i-1]))

"""         

#printデバッグ消した？

#前の問題の結果見てないのに次の問題に行くの？

"""

"""

お前カッコ閉じるの忘れてるだろ

"""

import sys

from io import StringIO

import unittest





class TestClass(unittest.TestCase):

    def assertIO(self, input, output):

        stdout, stdin = sys.stdout, sys.stdin

        sys.stdout, sys.stdin = StringIO(), StringIO(input)

        resolve()

        sys.stdout.seek(0)

        out = sys.stdout.read()[:-1]

        sys.stdout, sys.stdin = stdout, stdin

        self.assertEqual(out, output)



    def test_入力例_1(self):

        input = """5

1 1 2 1 2"""

        output = """2

2

3

2

3"""

        self.assertIO(input, output)



    def test_入力例_2(self):

        input = """4

1 2 3 4"""

        output = """0

0

0

0"""

        self.assertIO(input, output)



    def test_入力例_3(self):

        input = """5

3 3 3 3 3"""

        output = """6

6

6

6

6"""

        self.assertIO(input, output)



    def test_入力例_4(self):

        input = """8

1 2 1 4 2 1 4 1"""

        output = """5

7

5

7

7

5

7

5"""

        self.assertIO(input, output)





if __name__=="__main__":resolve()
#%% for atcoder uniittest use

import sys

input= lambda: sys.stdin.readline().rstrip()

def pin(type=int):return list(map(type,input().split()))

def tupin(t=int):return tuple(pin(t))

#%%code

def resolve():

    N=int(eval(input()))

    A=tupin()



    from collections import Counter

    c=Counter(A)

    total=0

    

    for t in list(c.items()):

        ag,b=t

        total+=(b*(b-1))//2

    #print(total)

    for m in A:

        a=c[m]

        print((total-((a*(a-1))//2)+((a-1)*(a-2))//2))

#%%submit!

resolve()
# coding: utf-8
# Your code here!
# coding: utf-8
import sys

sys.setrecursionlimit(10000000)
# const
dxdy = ((1, 0), (0, 1))
# my functions here!
def pin(type=int):
    return list(map(type, input().rstrip().split()))


def resolve():
    (N,) = pin()
    A = list(pin())
    from collections import Counter as ct

    a = ct(A)
    t = list(a.items())
    # print(t)
    Sum = 0
    for l in list(a.values()):
        Sum += (l * (l - 1)) // 2
    ans = [0] * N
    for j in list(a.items()):
        x, y = j
        ans[x - 1] = Sum - ((y * (y - 1)) // 2) + (((y - 2) * (y - 1)) // 2)
    for i in A:
        print((ans[i - 1]))


"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
1 1 2 1 2"""
        output = """2
2
3
2
3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
1 2 3 4"""
        output = """0
0
0
0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
3 3 3 3 3"""
        output = """6
6
6
6
6"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """8
1 2 1 4 2 1 4 1"""
        output = """5
7
5
7
7
5
7
5"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()

#%% for atcoder uniittest use
import sys

input = lambda: sys.stdin.readline().rstrip()


def pin(type=int):
    return list(map(type, input().split()))


def tupin(t=int):
    return tuple(pin(t))


#%%code
def resolve():
    N = int(eval(input()))
    A = tupin()
    from collections import Counter

    c = Counter(A)
    total = 0
    for t in list(c.items()):
        ag, b = t
        total += (b * (b - 1)) // 2
    # print(total)
    for m in A:
        a = c[m]
        print((total - ((a * (a - 1)) // 2) + ((a - 1) * (a - 2)) // 2))


#%%submit!
resolve()

-# coding: utf-8 -# Your code here! -# coding: utf-8 +#%% for atcoder uniittest use -sys.setrecursionlimit(10000000) -# const -dxdy = ((1, 0), (0, 1)) -# my functions here! -def pin(type=int): -    return list(map(type, input().rstrip().split())) +input = lambda: sys.stdin.readline().rstrip() -def resolve(): -    (N,) = pin() -    A = list(pin()) -    from collections import Counter as ct - -    a = ct(A) -    t = list(a.items()) -    # print(t) -    Sum = 0 -    for l in list(a.values()): -        Sum += (l * (l - 1)) // 2 -    ans = [0] * N -    for j in list(a.items()): -        x, y = j -        ans[x - 1] = Sum - ((y * (y - 1)) // 2) + (((y - 2) * (y - 1)) // 2) -    for i in A: -        print((ans[i - 1])) +def pin(type=int): +    return list(map(type, input().split())) -""" -#printデバッグ消した？ -#前の問題の結果見てないのに次の問題に行くの？ -""" -""" -お前カッコ閉じるの忘れてるだろ -""" -import sys -from io import StringIO -import unittest +def tupin(t=int): +    return tuple(pin(t)) -class TestClass(unittest.TestCase): -    def assertIO(self, input, output): -        stdout, stdin = sys.stdout, sys.stdin -        sys.stdout, sys.stdin = StringIO(), StringIO(input) -        resolve() -        sys.stdout.seek(0) -        out = sys.stdout.read()[:-1] -        sys.stdout, sys.stdin = stdout, stdin -        self.assertEqual(out, output) +#%%code +def resolve(): +    N = int(eval(input())) +    A = tupin() +    from collections import Counter -    def test_入力例_1(self): -        input = """5 -1 1 2 1 2""" -        output = """2 -2 -3 -2 -3""" -        self.assertIO(input, output) - -    def test_入力例_2(self): -        input = """4 -1 2 3 4""" -        output = """0 -0 -0 -0""" -        self.assertIO(input, output) - -    def test_入力例_3(self): -        input = """5 -3 3 3 3 3""" -        output = """6 -6 -6 -6 -6""" -        self.assertIO(input, output) - -    def test_入力例_4(self): -        input = """8 -1 2 1 4 2 1 4 1""" -        output = """5 -7 -5 -7 -7 -5 -7 -5""" -        self.assertIO(input, output) +    c = Counter(A) +    total = 0 +    for t in list(c.items()): +        ag, b = t +        total += (b * (b - 1)) // 2 +    # print(total) +    for m in A: +        a = c[m] +        print((total - ((a * (a - 1)) // 2) + ((a - 1) * (a - 2)) // 2)) -if __name__ == "__main__": -    resolve() +#%%submit! +resolve()