program BegC
  implicit none
  integer :: N, K, j!, hmax(1)                                                                
  integer(8),allocatable,dimension(:) :: H

  read(*,*) N, K
  allocate(H(N))
  read(*,*) (H(j) ,j=1,N)

!  print *, H                                                                                 

  if(K.ge.N) then
     print*, 0
     stop
  end if

  do j=1,K
!     hmax=maxloc(H)                                                                          
     !     H(hmax)=0                                                                          
     H(maxloc(H))=0
  enddo
!  print *, H                                                                                 
  print *, sum(H)


end program BegC