function Main(inp) {
	const input = inp.split("\n");
	const [n, k] = input[0].split(" ");
    const arr = input[1]
    	.split(" ")
    	.map((str) => Number(str))
    	.sort((a,b) => {
        	if(a < b) return 1
          	if(a > b) return -1
            return 0
        });
  	let ans = 0;
  	for(let i=0; i < k; i++){
    	ans += arr[i];
    }
	
	console.log(ans);
}
// Main(require("fs").readFileSync("/dev/stdin", "utf8"));
Main(
` 10 2
9 8 7 6 4 3 0 19 2 1`
)