"use strict";

function main(input) {
  input = input.trim().split("\n");
  const line_one = input[0].split(" ");
  const line_two = input[1].split(" ");

  for (const i in line_two) {
    line_two[i] = parseInt(line_two[i]);
  }

  let ans = 0;
  line_two.sort(f);
  for (let i = 0; i < line_one[1]; i++) {
    ans = ans + line_two[i];
  }
  console.log(ans);
}
var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));
