function main(input) {
  const [n, k] = input[0].trim().split(" ").map(i => parseInt(i));
  const p = input[1].trim().split(" ").map(i => parseInt(i)).sort(function(a, b) {return a - b;});

  const sum  = function(arr) {
    return arr.reduce(function(prev,current,i,arr) {return (i<k)?(prev+current):(prev)});
  };
  console.log(sum(p));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));