const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split("\n")
    const [N, K] = lines[0].split(" ").map(Number)
    const p = lines[1].split(" ").map(Number)

    p.sort((a, b) => a - b)

    let sum = 0;
    for(let i = 0; i < K; i++) {
        sum += p[i]
    }

    console.log(sum)

})(input)

