function Main(input) {
    input = input.split("\n");
    tmp1 = input[0].split(" ");
    tmp2 = input[1].split(" ");
    
    var n = parseInt(tmp1[0], 10);
    var k = parseInt(tmp1[1], 10);
    
	for (var i = 0; i < n; i++) {
	tmp2[i]=parseInt(tmp2[i], 10);
	}
	
    var p = tmp2;
    
    p.sort(function(a,b){
        if( a < b ) return -1;
        if( a > b ) return 1;
        return 0;
	});
    
    var result = 0
	for (var i = 0; i < k; i++) {
	result = result + p[i];
	}
    
	console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));