function main(lines) {
  const [N, K] = splitN(lines[0]);
  const ps = splitN(lines[1]).sort((a, b) => a-b);

  let res = 0;
  for (let i = 0; i < K; i++) {
    res += ps[i];
  }
  
  console.log(res);
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}