program ABC153C
    implicit none
    integer(8)::N,K,i,result
    integer(8),allocatable,dimension(:)::H
    read(5,*)N,K
    allocate(H(N))
    read(5,*)(H(i),i=1,N)
    H=iqsort(H)
    result=sum(H)
    do i=0,min(N,K)-1
        result=result-H(N-i)
    end do

    print'(i0)',result

contains
    recursive function iqsort(ix) result(ires)
      integer(8), allocatable :: ires(:)
      integer(8), intent(in)  :: ix(:)
      integer :: k
      if (size(ix) <= 1) then 
        ires = ix
      else  
        k = ix(size(ix) / 2)
        ires = [iqsort(pack(ix, ix < k)), pack(ix, ix == k), iqsort(pack(ix, ix > k))] 
      end if
    end function iqsort
end program ABC153C