function Main(input){
    const arr = input.split('\n');
    const NK = arr[0].split(' ').map(Number);
    const pn = arr[1].split(' ').map(Number);
    let answer = 0;
    pn.sort((a,b)=> a - b);
    for(let i=0; i<NK[1]; i++){
        answer += pn[i];
    }
    console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));