      PROGRAM piyo
      IMPLICIT NONE
      integer(16) :: n
      integer(16),allocatable :: a(:),counter(:),memo(:)
      integer(16) :: i,mm,buffer,memo2
      
      read*,n
      allocate( a(n),counter(n),memo(n) )
      read*,a(:)
      
      counter = 0
      do i = 1,n
        counter( a(i) ) = counter( a(i) ) + 1
      end do
      
      do i = 1,n
        mm = counter(i)
        memo( i ) = mm*(mm-1)/2
      end do
      memo2 = sum( memo )
      
      
      do i = 1,n
        mm = counter(a(i))
        buffer = memo2
        buffer = buffer - mm*(mm-1)/2
        mm = mm-1
        buffer = buffer + mm*(mm-1)/2
        print*,buffer
      end do
      
      
      
      
      END PROGRAM