const main = input => {
  let [a, b] = input.split('\n');
  let [n, k] = a.split(' ');
  let ans = b.split(' ').map(x => Number(x)).sort((a, b) => a - b).reduce((acc, current, index, array) => {
    if (index < k) {
      return acc + current;
    } else {
      return acc;
    }
  });
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));