function Main(input) {
  var s = input.split('\n')[0].split(" ")[1];
  var p = input.split('\n')[1].split(" ").map(el => parseInt(el)).sort(
    function(a,b){return a<b?-1:a>b?1:0;
  });
  console.log(p.slice(0,s==1?1:s-1).reduce((sum,cV)=>sum+cV))
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
