N=int(eval(input()))

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

dic={}

for a in A:

  if a in list(dic.keys()):

    dic[a]+=1

  else:

    dic[a]=1

r=0

for a in list(dic.keys()):

  c=dic[a]

  r+=c*(c-1)//2

for i in range(N):

  c=dic[A[i]]

  print((r - c*(c-1)//2 + (c-1)*(c-2)//2 ))

#!/usr/bin python3

# -*- coding: utf-8 -*-



import sys

input = sys.stdin.readline



def main():

    N = int(eval(input()))

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

    D = {}

    for a in A:

        if a in D:

            D[a]+=1

        else:

            D[a]=1

    ret = 0

    for d in D:

        ret += D[d]*(D[d]-1)//2

    for a in A:

        print((ret - D[a]*(D[a]-1)//2 + (D[a]-1)*(D[a]-2)//2 ))





if __name__ == '__main__':

    main()
N = int(eval(input()))
A = list(map(int, input().split()))
dic = {}
for a in A:
    if a in list(dic.keys()):
        dic[a] += 1
    else:
        dic[a] = 1
r = 0
for a in list(dic.keys()):
    c = dic[a]
    r += c * (c - 1) // 2
for i in range(N):
    c = dic[A[i]]
    print((r - c * (c - 1) // 2 + (c - 1) * (c - 2) // 2))

#!/usr/bin python3
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    D = {}
    for a in A:
        if a in D:
            D[a] += 1
        else:
            D[a] = 1
    ret = 0
    for d in D:
        ret += D[d] * (D[d] - 1) // 2
    for a in A:
        print((ret - D[a] * (D[a] - 1) // 2 + (D[a] - 1) * (D[a] - 2) // 2))


if __name__ == "__main__":
    main()

-N = int(eval(input())) -A = list(map(int, input().split())) -dic = {} -for a in A: -    if a in list(dic.keys()): -        dic[a] += 1 -    else: -        dic[a] = 1 -r = 0 -for a in list(dic.keys()): -    c = dic[a] -    r += c * (c - 1) // 2 -for i in range(N): -    c = dic[A[i]] -    print((r - c * (c - 1) // 2 + (c - 1) * (c - 2) // 2)) +#!/usr/bin python3 +# -*- coding: utf-8 -*- +import sys + +input = sys.stdin.readline + + +def main(): +    N = int(eval(input())) +    A = list(map(int, input().split())) +    D = {} +    for a in A: +        if a in D: +            D[a] += 1 +        else: +            D[a] = 1 +    ret = 0 +    for d in D: +        ret += D[d] * (D[d] - 1) // 2 +    for a in A: +        print((ret - D[a] * (D[a] - 1) // 2 + (D[a] - 1) * (D[a] - 2) // 2)) + + +if __name__ == "__main__": +    main()