from math import factorial

from functools import lru_cache



@lru_cache(maxsize=None)

def cmbcount(n):

    if n > 1:

        return factorial(n) // (factorial(n - 2) * factorial(2))

    return 0



N = int(eval(input()))

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

samecnt = [0] * (N + 1)

for a in A:

    samecnt[a] += 1

cnts = [cmbcount(n) for n in samecnt]

allcnt = sum(cnts)

for i in range(N):

    a = A[i]

    o = cnts[a]

    n = cmbcount(samecnt[a] - 1)

    ans = allcnt - (o - n)

    print(ans)
N = int(eval(input()))

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

c = [0] * (N + 1)

for a in A:

    c[a] += 1

total = sum([n * (n - 1) // 2 for n in c])

for a in A:

    print((total - (c[a] - 1)))
from math import factorial
from functools import lru_cache


@lru_cache(maxsize=None)
def cmbcount(n):
    if n > 1:
        return factorial(n) // (factorial(n - 2) * factorial(2))
    return 0


N = int(eval(input()))
A = list(map(int, input().split()))
samecnt = [0] * (N + 1)
for a in A:
    samecnt[a] += 1
cnts = [cmbcount(n) for n in samecnt]
allcnt = sum(cnts)
for i in range(N):
    a = A[i]
    o = cnts[a]
    n = cmbcount(samecnt[a] - 1)
    ans = allcnt - (o - n)
    print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
c = [0] * (N + 1)
for a in A:
    c[a] += 1
total = sum([n * (n - 1) // 2 for n in c])
for a in A:
    print((total - (c[a] - 1)))

-from math import factorial -from functools import lru_cache - - -@lru_cache(maxsize=None) -def cmbcount(n): -    if n > 1: -        return factorial(n) // (factorial(n - 2) * factorial(2)) -    return 0 - - -samecnt = [0] * (N + 1) +c = [0] * (N + 1) -    samecnt[a] += 1 -cnts = [cmbcount(n) for n in samecnt] -allcnt = sum(cnts) -for i in range(N): -    a = A[i] -    o = cnts[a] -    n = cmbcount(samecnt[a] - 1) -    ans = allcnt - (o - n) -    print(ans) +    c[a] += 1 +total = sum([n * (n - 1) // 2 for n in c]) +for a in A: +    print((total - (c[a] - 1)))