function Main(input) {
  const N = parseInt(input.split(/\n| /)[0]);
  const K = parseInt(input.split(/\n| /)[1]);
  var p = input.split("\n")[1].split(" ").map(n => parseInt(n));
  p.sort(compareFunc);

  var result = p.slice(0, K).reduce((a, b) => { return a + b }, 0);
  console.log(result);

}

function compareFunc(a, b) {
  return a - b;
}

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