const main = input => {
  const inputs = input.split("\n");
  const [n, k] = inputs[0].split(" ").map(Number);
  const prices = inputs[1].split(" ").map(Number);
  prices.sort((a, b) => a - b);
  const sum = prices.slice(0, k).reduce((a, v) => {
    return a + v;
  }, 0);
  console.log(sum);
}

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