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_cnt = 0
  var new_m = monster_hp.sort((a,b) => a-b)
  var m = (cnt - special) > 0 ? cnt - special: 0
  if (m == 0) {
    console.log(0)
  } else if (m == 1){
    var r = new_m.shift()
    console.log(r)
  } else {
    var r = new_m.slice(0, m).reduce((a,x) => a+=x, 0)
    console.log(r)
  }
});