function Main(inputs) {
	const inputlines = inputs.split("\n");
 	const firstvalues = inputlines[0].split(" ");
  	let prices = inputlines[1].split(" ").map(x => parseInt(x, 10));
  
  	prices.sort((a,b)　=> a - b);
  	
  	let total = 0;
  	for(let i = 0; i < firstvalues[1]; i++){
      total += prices[i];
    }
  
  	console.log(total);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));