program main
  
  implicit none

  integer(8) :: n
  integer(8), allocatable :: a(:), b(:), c(:)

  integer(8) :: i,j, tmp
  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
    if( mod(c(i),2) == 0 ) then
      tmp =  int( c(i)/2 )
      b(i) =  tmp*(c(i)-1)
    else
      tmp = int( (c(i)-1)/2 )
      b(i) =  c(i)*tmp
    end if
    sumb = sumb + b(i)
  end do

  do i = 1, n
    if( mod(c(a(i)),2) == 0 ) then
      tmp = int( (c(a(i))-2)/2 )
      print*, sumb - b(a(i)) + tmp*(c(a(i))-1)
    else
      tmp = int( (c(a(i))-1)/2 )
      print*, sumb - b(a(i)) + tmp*(c(a(i))-2)
    end if
  end do
  
  
end program main
