n = int(eval(input()))

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



def factorial(n):

    v = 1

    for i in range(1, n + 1):

        v *= i

    return v



def comb(a, b):

    return factorial(a) // (factorial(b) * factorial(a - b))



from collections import Counter

acnt = dict(Counter(a))

value = list(acnt.values())

sv = 0

for i in range(len(value)):

    if value[i] > 1:

        sv += (value[i]*(value[i]-1))//2

for i in range(n):

    cur = a[i]

    cursv = sv

    if acnt[cur] > 2:

        cursv = cursv - acnt[cur] + 1

    elif acnt[cur] == 2:

        cursv -= 1

    print(cursv)

n = int(eval(input()))

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



from collections import Counter

acnt = dict(Counter(a))

value = list(acnt.values())

sv = 0

for i in range(len(value)):

    if value[i] > 1:

        sv += (value[i]*(value[i]-1))//2

for i in range(n):

    cur = a[i]

    cursv = sv

    if acnt[cur] > 2:

        cursv = cursv - acnt[cur] + 1

    elif acnt[cur] == 2:

        cursv -= 1

    print(cursv)

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


def factorial(n):
    v = 1
    for i in range(1, n + 1):
        v *= i
    return v


def comb(a, b):
    return factorial(a) // (factorial(b) * factorial(a - b))


from collections import Counter

acnt = dict(Counter(a))
value = list(acnt.values())
sv = 0
for i in range(len(value)):
    if value[i] > 1:
        sv += (value[i] * (value[i] - 1)) // 2
for i in range(n):
    cur = a[i]
    cursv = sv
    if acnt[cur] > 2:
        cursv = cursv - acnt[cur] + 1
    elif acnt[cur] == 2:
        cursv -= 1
    print(cursv)

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

acnt = dict(Counter(a))
value = list(acnt.values())
sv = 0
for i in range(len(value)):
    if value[i] > 1:
        sv += (value[i] * (value[i] - 1)) // 2
for i in range(n):
    cur = a[i]
    cursv = sv
    if acnt[cur] > 2:
        cursv = cursv - acnt[cur] + 1
    elif acnt[cur] == 2:
        cursv -= 1
    print(cursv)

- - -def factorial(n): -    v = 1 -    for i in range(1, n + 1): -        v *= i -    return v - - -def comb(a, b): -    return factorial(a) // (factorial(b) * factorial(a - b)) - -