program example
	implicit none

	integer(8) :: N,K,i,wa=0
    integer(8),allocatable :: H(:)
    
    read(*,*) N,K
    
    allocate(H(N))
    
    read(*,*) H(:)
    
    do i=1,K
        
        if (sum(H)==0) then
        	exit
        else
            H(maxloc(H(:),1))=0
        end if
    end do
    
    wa=wa+sum(H(:))
    
    write(*,*) wa

end program example