n=int(eval(input()))

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

a0=[ai for ai in a]

a0.sort()

b=[-1]*(n+1)

base=0

i=0

while i < n:

    t=a0[i]

    c=1

    while i < n-1 and a0[i]==a0[i+1]:

        c+=1

        i+=1

    b[t]=c

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

    i+=1

for i in range(n):

    d=b[a[i]]

    print((base-d+1))
n=int(eval(input()))

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

from collections import Counter

ca=Counter(a)

ans=sum([(v*(v-1))//2 for v in list(ca.values())])

for ai in a:

  print((ans-ca[ai]+1))
n = int(eval(input()))
a = list(map(int, input().split()))
a0 = [ai for ai in a]
a0.sort()
b = [-1] * (n + 1)
base = 0
i = 0
while i < n:
    t = a0[i]
    c = 1
    while i < n - 1 and a0[i] == a0[i + 1]:
        c += 1
        i += 1
    b[t] = c
    base += c * (c - 1) // 2
    i += 1
for i in range(n):
    d = b[a[i]]
    print((base - d + 1))

n = int(eval(input()))
a = list(map(int, input().split()))
from collections import Counter

ca = Counter(a)
ans = sum([(v * (v - 1)) // 2 for v in list(ca.values())])
for ai in a:
    print((ans - ca[ai] + 1))

-a0 = [ai for ai in a] -a0.sort() -b = [-1] * (n + 1) -base = 0 -i = 0 -while i < n: -    t = a0[i] -    c = 1 -    while i < n - 1 and a0[i] == a0[i + 1]: -        c += 1 -        i += 1 -    b[t] = c -    base += c * (c - 1) // 2 -    i += 1 -for i in range(n): -    d = b[a[i]] -    print((base - d + 1)) +from collections import Counter + +ca = Counter(a) +ans = sum([(v * (v - 1)) // 2 for v in list(ca.values())]) +for ai in a: +    print((ans - ca[ai] + 1))