def main():

    n = int(eval(input()))

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

    import collections

    c =collections.Counter(a)

    ans = 0

    for k in list(c.keys()):

        ans += c[k]*(c[k]-1)//2

    for i in range(n):

        draw = c[a[i]]*(c[a[i]]-1)//2-(c[a[i]]-1)*(c[a[i]]-2)//2

        print((ans-draw))



if __name__ == "__main__":

    main()
def main():

    n = int(eval(input()))

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

    d = {}

    for i in range(n):

        if d.get(a[i]) == None:

            d[a[i]] = 1

        else:

            d[a[i]] += 1

    ans = 0

    for k in list(d.keys()):

        ans += d[k] * (d[k]-1) //2

    for i in range(n):

        print((ans - ((d[a[i]]*(d[a[i]]-1))//2 - (d[a[i]]-1) * (d[a[i]]-2)//2)))



if __name__ == "__main__":

    main()

def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    import collections

    c = collections.Counter(a)
    ans = 0
    for k in list(c.keys()):
        ans += c[k] * (c[k] - 1) // 2
    for i in range(n):
        draw = c[a[i]] * (c[a[i]] - 1) // 2 - (c[a[i]] - 1) * (c[a[i]] - 2) // 2
        print((ans - draw))


if __name__ == "__main__":
    main()

def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    d = {}
    for i in range(n):
        if d.get(a[i]) == None:
            d[a[i]] = 1
        else:
            d[a[i]] += 1
    ans = 0
    for k in list(d.keys()):
        ans += d[k] * (d[k] - 1) // 2
    for i in range(n):
        print(
            (
                ans
                - ((d[a[i]] * (d[a[i]] - 1)) // 2 - (d[a[i]] - 1) * (d[a[i]] - 2) // 2)
            )
        )


if __name__ == "__main__":
    main()

-    import collections - -    c = collections.Counter(a) +    d = {} +    for i in range(n): +        if d.get(a[i]) == None: +            d[a[i]] = 1 +        else: +            d[a[i]] += 1 -    for k in list(c.keys()): -        ans += c[k] * (c[k] - 1) // 2 +    for k in list(d.keys()): +        ans += d[k] * (d[k] - 1) // 2 -        draw = c[a[i]] * (c[a[i]] - 1) // 2 - (c[a[i]] - 1) * (c[a[i]] - 2) // 2 -        print((ans - draw)) +        print( +            ( +                ans +                - ((d[a[i]] * (d[a[i]] - 1)) // 2 - (d[a[i]] - 1) * (d[a[i]] - 2) // 2) +            ) +        )