const [nk, pStr] = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/)
const [n, k] = nk.split(/\s/).map(Number)
const ps = pStr.split(/\s/).map(Number)
ps.sort((a, b) => a - b)
let result = 0
for (let i = 0; i < k; i++) {
  result += ps[i]
}
console.log(result)