const input = require("fs").readFileSync("/dev/stdin", "utf8")
let cin = input.split(/ |\n/), cid = 0
const next = () => cin[cid++]
const nexts = (n) => cin.slice(cid, cid+=n).map(i=>parseInt(i))

const [N, K] = nexts(2)
const P = nexts(N)

priceList = P.sort((a, b) => a - b)
console.log(priceList.slice(0, K).reduce((prev, cur) => prev+ cur, 0))
