from collections import Counter





def choose(n, r):

    x, y = 1, 1

    for i in range(r):

        x *= n - i

        y *= i + 1

    return x // y





N = int(input())

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



ctr = Counter(a)



b = 0

for cnt in ctr.values():

    b += choose(cnt, 2)



ret = []

for x in a:

    cnt = ctr[x]

    res = b - choose(cnt, 2) + choose(cnt - 1, 2)

    ret.append(res)



print(*ret, sep='\n')

def main():

    from collections import Counter

    N = int(input())

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



    ctr = Counter(a)

    frm_n = sum(x * (x - 1) // 2 for x in ctr.values())



    ans = []

    for x in a:

        ans.append(frm_n - ctr[x] + 1)



    print(*ans, sep='\n')





if __name__ == '__main__':

    main()



# import sys

# input = sys.stdin.readline

# 

# sys.setrecursionlimit(10 ** 7)

# 

# (int(x)-1 for x in input().split())

# rstrip()

#

# def binary_search(*, ok, ng, func):

#     while abs(ok - ng) > 1:

#         mid = (ok + ng) // 2

#         if func(mid):

#             ok = mid

#         else:

#             ng = mid

#     return ok

from collections import Counter


def choose(n, r):
    x, y = 1, 1
    for i in range(r):
        x *= n - i
        y *= i + 1
    return x // y


N = int(input())
(*a,) = map(int, input().split())
ctr = Counter(a)
b = 0
for cnt in ctr.values():
    b += choose(cnt, 2)
ret = []
for x in a:
    cnt = ctr[x]
    res = b - choose(cnt, 2) + choose(cnt - 1, 2)
    ret.append(res)
print(*ret, sep="\n")

def main():
    from collections import Counter

    N = int(input())
    (*a,) = map(int, input().split())
    ctr = Counter(a)
    frm_n = sum(x * (x - 1) // 2 for x in ctr.values())
    ans = []
    for x in a:
        ans.append(frm_n - ctr[x] + 1)
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()
# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok

-from collections import Counter +def main(): +    from collections import Counter + +    N = int(input()) +    (*a,) = map(int, input().split()) +    ctr = Counter(a) +    frm_n = sum(x * (x - 1) // 2 for x in ctr.values()) +    ans = [] +    for x in a: +        ans.append(frm_n - ctr[x] + 1) +    print(*ans, sep="\n") -def choose(n, r): -    x, y = 1, 1 -    for i in range(r): -        x *= n - i -        y *= i + 1 -    return x // y - - -N = int(input()) -(*a,) = map(int, input().split()) -ctr = Counter(a) -b = 0 -for cnt in ctr.values(): -    b += choose(cnt, 2) -ret = [] -for x in a: -    cnt = ctr[x] -    res = b - choose(cnt, 2) + choose(cnt - 1, 2) -    ret.append(res) -print(*ret, sep="\n") +if __name__ == "__main__": +    main() +# import sys +# input = sys.stdin.readline +# +# sys.setrecursionlimit(10 ** 7) +# +# (int(x)-1 for x in input().split()) +# rstrip() +# +# def binary_search(*, ok, ng, func): +#     while abs(ok - ng) > 1: +#         mid = (ok + ng) // 2 +#         if func(mid): +#             ok = mid +#         else: +#             ng = mid +#     return ok