program main
    implicit none
    integer(8), allocatable:: h(:)
    integer(8):: n, k, one, ans, i
    one =1
    read*, n, k
    
    if (k >= n)then
        print*, 0
        stop
    end if
    
    allocate(h(n))
    read*, h(:)
    call marge_sort(h(:), one, n)
    h(1:k) = 0
    print*, sum(h(:))
contains
recursive subroutine marge_sort(arr,first,last)
    integer(8):: arr(:), tmp
    integer(8):: first, last, mean

    if (last - first <= 2) then
        if (arr(first) <= arr(last))then
            tmp = arr(first)
            arr(first) = arr(last)
            arr(last) = tmp
        end if
        return
    end if
    
    mean = (first + last) / 2
    call marge_sort(arr, first, mean)
    call marge_sort(arr, mean+1, last)
    call marge(arr, first, mean, last)

end subroutine


subroutine marge(arr, first, mean, last)
    integer(8):: arr(:)
    integer(8), allocatable:: tmp(:)
    integer(8):: first, mean, last
    integer(8):: i, i_left, i_right
    
    allocate(tmp(last-first+1))
    i_left = first
    i_right = mean + 1
    i = 0
    do while((i_left <= mean) .and. (i_right <= last))
        i = i + 1
        if (arr(i_left) >= arr(i_right))then
            tmp(i) = arr(i_left)
            i_left = i_left + 1
        else
            tmp(i) = arr(i_right)
            i_right = i_right + 1
        end if
    end do

    if (i_left > mean)then
        tmp(i+1:) = arr(i_right:last)
    else
        tmp(i+1:) = arr(i_left:mean)
    end if
    arr(first:last) = tmp(:)

end subroutine
end program main