from sys import stdin,setrecursionlimit

n = int(stdin.readline().rstrip())

li = list(map(int,stdin.readline().rstrip().split()))

lin = [0]*(n+1)

for i in li:

    lin[i] += 1

liv = [0]*(n+1)

point = 0

for j,k in enumerate(lin):

    point += k*(k-1)//2

    liv[j] += k*(k-1)//2

for i in li:

    print((point-liv[i]+(lin[i]-1)*(lin[i]-2)//2))
N = int(eval(input()))

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



#各要素が何個あるか

num_list = [0]*(N+1)

for i in A:

    num_list[i] += 1



#全体の組み合わせ

total = 0

for j in num_list:

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



for k in A:

    print((total+1-num_list[k]))
from sys import stdin, setrecursionlimit

n = int(stdin.readline().rstrip())
li = list(map(int, stdin.readline().rstrip().split()))
lin = [0] * (n + 1)
for i in li:
    lin[i] += 1
liv = [0] * (n + 1)
point = 0
for j, k in enumerate(lin):
    point += k * (k - 1) // 2
    liv[j] += k * (k - 1) // 2
for i in li:
    print((point - liv[i] + (lin[i] - 1) * (lin[i] - 2) // 2))

N = int(eval(input()))
A = list(map(int, input().split()))
# 各要素が何個あるか
num_list = [0] * (N + 1)
for i in A:
    num_list[i] += 1
# 全体の組み合わせ
total = 0
for j in num_list:
    total += j * (j - 1) // 2
for k in A:
    print((total + 1 - num_list[k]))

-from sys import stdin, setrecursionlimit - -n = int(stdin.readline().rstrip()) -li = list(map(int, stdin.readline().rstrip().split())) -lin = [0] * (n + 1) -for i in li: -    lin[i] += 1 -liv = [0] * (n + 1) -point = 0 -for j, k in enumerate(lin): -    point += k * (k - 1) // 2 -    liv[j] += k * (k - 1) // 2 -for i in li: -    print((point - liv[i] + (lin[i] - 1) * (lin[i] - 2) // 2)) +N = int(eval(input())) +A = list(map(int, input().split())) +# 各要素が何個あるか +num_list = [0] * (N + 1) +for i in A: +    num_list[i] += 1 +# 全体の組み合わせ +total = 0 +for j in num_list: +    total += j * (j - 1) // 2 +for k in A: +    print((total + 1 - num_list[k]))