function Main(inputs) {
  var lines = inputs.split('\n')

  var N = +(lines[0].split(' ')[0])
  var K = +(lines[0].split(' ')[1])

  var HitPoints = lines[1]
    .split(' ')
    .map(v=>+v)

  var size = Math.max(N - K,0)
  console.log(cobo_sort(HitPoints,size).slice(0,size).reduce((s,v)=>s+v,0))
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function cobo_sort(list,size) {
  var pos = list[0]
  var a = list.filter(x=> +x <= +pos)
  var b = list.filter(x=> +pos < +x)

  if(a.length < size){
    return a.sort((a,b)=> a>b ? 1 : -1)
  }
  return [...a,...b.sort((a,b)=> a>b ? 1 : -1)]
}
