program main
      implicit none
      integer(4) :: n
      integer(4), allocatable :: a(:), num(:)
      integer(4) :: i, j, k, cnt

      read(*,*) n
      allocate( a(n) )
      read(*,*) a
      
      allocate( num(n) )
      num(:) = 0

      do i = 1, n
        j = a(i)
        num(j) = num(j) + 1
      end do
      
      do i = 1, n
        j = a(i)
        num(j) = num(j) - 1
        cnt = 0
        do k = 1, n
          cnt = cnt + num(k) * ( num(k) - 1 ) / 2
        end do
        print *, cnt
        num(j) = num(j) + 1
      end do
      
end program
