var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  var line = lines[0].split(" ").map(x => Number(x))
  var monster_hp = lines[1].split(" ").map(x => Number(x))
  var cnt = line[0]
  var special = line[1]
  var tmp = Math.max.apply
  var tmp_cnt = 0
  for(var i = 0; i < special; i++) {
    var max = Math.max.apply(null, monster_hp)
    monster_hp.splice(monster_hp.indexOf(max), 1)
  }
  const t = monster_hp.reduce((a,x) => a+=x, 0)
  if (t != 0) {
    console.log(t)
  } else {
    console.log(0)
  }
});