"use strict";

function main(arg) {
    const input = arg.split("\n")
    const [N,K] = input[0].split(" ").map(x=>Number(x))
    const p = input[1].split(" ").map(x=>Number(x)).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"));