"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const [n, k] = spi[0].split(' ').map(e => parseInt(e));
    const p = spi[1].split(' ').map(e => parseInt(e));

    p.sort(function(a, b){
        return a - b;
    });

    let ans = 0;
    for (let i = 0; i < k; i++) {
        ans += p[i];
    }

    console.log(ans);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));
