"use strict";

function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    let tmp = input[0].split(" ");
    let n = parseInt(tmp[0], 10);
    let k = parseInt(tmp[1], 10);
    let p = input[1].split(" ").map(str => parseInt(str, 10));

    p.sort(compareFunc);    //昇順に並べ替え

    let total = 0;

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

    //出力
    console.log('%d', total);
}

function compareFunc(a, b) {
    return a - b;
}

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