const Main = input => {
    input = input.split("\n");
    const nk = input[0].split(" ").map(value => parseInt(value, 10));

    const n = nk[0];
    const k = nk[1];
    const p = input[1].split(" ").map(value => parseInt(value, 10));

    //pを昇順でソート
    p.sort((a, b) => {
        return a - b;
    });

    let minTotal = 0;
    for(let i = 0; i < k; i++) {
        minTotal += p[i];
    }
    
    console.log(minTotal);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));