      module sortMod
        implicit none
        
        contains
        
        subroutine bSort( a ,kk )
          implicit none
          integer(16) :: a(:)
          integer(16) :: n,i,k,buffer,kk
          
          n = size(a)
          if( kk==n ) kk = kk -1
          
          do i = 1,k
            do k = i+1,n
              if( a(i)<a(k) )then
                buffer = a(i)
                a(i) = a(k)
                a(k) = buffer
              end if
            end do
          end do
        end subroutine
        
        recursive function qSort( a ) result( r )
          integer(16) :: a(:)
          integer(16),allocatable :: r(:)
          integer(16) :: k
          
          if( size(a)<=1 )then
            r = a
          else
            k = a(size(a)/2)
            r = [qSort(pack(a,a<k)),pack(a,a==r),qSort(pack(a,a>k))]
          end if
        end function qSort
      end module
      
      PROGRAM piyo
      use sortMod
      IMPLICIT NONE
      integer(16) :: n,k
      integer(16),allocatable :: h(:),sh(:)
      
      read*,n,k
      allocate(h(n),sh(n))
      read*,h
      
      call bsort( h,k )
      !sh = qSort( h )
      
      if( k/=0 )then
        h(1:k) = 0
      end if
      
      
      print*,sum(h)
      
      
      
      END PROGRAM