program example
	implicit none

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

end program example