    program main
      
      implicit none
     
      integer :: n
      integer(8), allocatable :: a(:), b(:), c(:)
     
      integer :: i,j
      integer(8) :: sumb
     
      read(*,*) n
      allocate( a(n) )
      allocate( b(n) )
      allocate( c(n) )
      read(*,*) a
     
      b = 0  
      c = 0  
      do i = 1, n
        c(a(i)) =  c(a(i)) + 1
      end do
      sumb = 0
      do i = 1, n
        b(i) =  c(i)*(c(i)-1)/2
        sumb = sumb + b(i)
      end do
     
      do i = 1, n
        print*, sumb - b(a(i)) + (c(a(i))-2)*(c(a(i))-1)/2
      end do
      
      
    end program main
