"use strict"
function main(arg) {
    let [N,K] = arg.trim().split("\n")[0].split(" ").map(Number)
    let p = arg.trim().split("\n")[1].split(" ").map(Number).sort((a,b)=>a-b)
    let sum = 0
    for (let i = 0; i < K; i++) {
        sum += p[i]
    }
    console.log(sum)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));