"use strict";

const func = (input) => {
    const a = input.split('\n');
    const [N, K] = a[0].split(" ").map(e => parseInt(e));
    let array = a[1].split(" ").map(e => parseInt(e));

    array.sort(function (x, y) {
        return x - y;
    });

    let ans = 0;
    for (let i = 0; i < K; i++) {
        ans += array[i];
    }
    console.log(ans);
}

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