import math

from collections import Counter



def mycounter(d,i):

    if i in d:

        d[i]+=1

    else:

        d[i]=1

    return d

    

def ABC159D(a):

    if a<2:

        return 0

    else:

        return math.factorial(a)//math.factorial(a-2)//2



n=int(eval(input()))

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

d = dict()

#for i in a:

#    d=mycounter(d,i)

dd=Counter(a)

#print(d)

p=0

for i in list(dd.values()):p+=ABC159D(i)

print(('\n'.join(map(str,[p-dd[i]+1 for i in a]))))
import math

from collections import Counter



def mycounter(d,i):

    if i in d:

        d[i]+=1

    else:

        d[i]=1

    return d

    

def ABC159D(a):

    if a<2:

        return 0

    else:

        return (a*(a-1))//2



n=int(eval(input()))

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

d = dict()

#for i in a:

#    d=mycounter(d,i)

dd=Counter(a)

#print(d)

p=0

for i in list(dd.values()):p+=ABC159D(i)

print(('\n'.join(map(str,[p-dd[i]+1 for i in a]))))
import math
from collections import Counter


def mycounter(d, i):
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
    return d


def ABC159D(a):
    if a < 2:
        return 0
    else:
        return math.factorial(a) // math.factorial(a - 2) // 2


n = int(eval(input()))
a = list(map(int, input().split()))
d = dict()
# for i in a:
#    d=mycounter(d,i)
dd = Counter(a)
# print(d)
p = 0
for i in list(dd.values()):
    p += ABC159D(i)
print(("\n".join(map(str, [p - dd[i] + 1 for i in a]))))

import math
from collections import Counter


def mycounter(d, i):
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
    return d


def ABC159D(a):
    if a < 2:
        return 0
    else:
        return (a * (a - 1)) // 2


n = int(eval(input()))
a = list(map(int, input().split()))
d = dict()
# for i in a:
#    d=mycounter(d,i)
dd = Counter(a)
# print(d)
p = 0
for i in list(dd.values()):
    p += ABC159D(i)
print(("\n".join(map(str, [p - dd[i] + 1 for i in a]))))

-        return math.factorial(a) // math.factorial(a - 2) // 2 +        return (a * (a - 1)) // 2