from operator import mul

from functools import reduce



def ncr(n,r):

    r = min(n-r,r)

    if r == 0: return 1

    over = reduce(mul, list(range(n, n - r, -1)))

    under = reduce(mul, list(range(1,r + 1)))

    return over // under



a = int(eval(input()))

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

d = {}

for k in A:

  if k in d:

    d[k] += 1

  else:

    d[k] = 1

 

res = 0

for k in d:

    if d[k] >= 2:

      res += ncr(d[k], 2)



for k in A:

  temp = res

  m = d[k]

  d[k] -= 1

  if m >= 2:

    temp -= ncr(m, 2)



  if d[k] >= 2:

    temp += ncr(d[k], 2)

  print(temp)

  d[k] += 1

from operator import mul

from functools import reduce



def ncr(n,r):

    r = min(n-r,r)

    if r == 0: return 1

    over = reduce(mul, list(range(n, n - r, -1)))

    under = reduce(mul, list(range(1,r + 1)))

    return over // under



a = int(eval(input()))

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

d = {}

for k in A:

  if k in d:

    d[k] += 1

  else:

    d[k] = 1

 

res = 0

for k in list(d.values()):

    if k >= 2:

      res += ncr(k, 2)



for k in A:

  temp = res

  m = d[k]

  if m >= 2:

    temp -= ncr(m, 2)



  d[k] -= 1

  if d[k] >= 2:

    temp += ncr(d[k], 2)

  print(temp)

  d[k] += 1

from operator import mul
from functools import reduce


def ncr(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, list(range(n, n - r, -1)))
    under = reduce(mul, list(range(1, r + 1)))
    return over // under


a = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for k in A:
    if k in d:
        d[k] += 1
    else:
        d[k] = 1
res = 0
for k in d:
    if d[k] >= 2:
        res += ncr(d[k], 2)
for k in A:
    temp = res
    m = d[k]
    d[k] -= 1
    if m >= 2:
        temp -= ncr(m, 2)
    if d[k] >= 2:
        temp += ncr(d[k], 2)
    print(temp)
    d[k] += 1

from operator import mul
from functools import reduce


def ncr(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, list(range(n, n - r, -1)))
    under = reduce(mul, list(range(1, r + 1)))
    return over // under


a = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for k in A:
    if k in d:
        d[k] += 1
    else:
        d[k] = 1
res = 0
for k in list(d.values()):
    if k >= 2:
        res += ncr(k, 2)
for k in A:
    temp = res
    m = d[k]
    if m >= 2:
        temp -= ncr(m, 2)
    d[k] -= 1
    if d[k] >= 2:
        temp += ncr(d[k], 2)
    print(temp)
    d[k] += 1

-for k in d: -    if d[k] >= 2: -        res += ncr(d[k], 2) +for k in list(d.values()): +    if k >= 2: +        res += ncr(k, 2) -    d[k] -= 1 +    d[k] -= 1