program sample
    implicit none
  
    integer(8) :: i,j,m,n,b
    integer(8),allocatable :: a(:),y(:)
  
    read(*,*) n
    allocate(a(n),y(n))
    read(*,*)a
    y(:)=0
    do i=1,n
        b=a(i)
        y(b)=y(b)+1
    end do
    m=0
    do i=1,n
        b=y(i)
        m=m+b*(b-1)/2
       
    end do
    do i=1,n
        b=a(i)
        if(y(b)<2)then
            write(*,*)m
        else
            write(*,*)m-y(b)+1
        end if
    end do
  
    stop
end program sample
  

