function Main(input) {
  let i = input.split("\n")
  let count = i[0].split(" ")[1]
  let price = 0
  let all = i[1].split(" ")
  all = all.sort((a,b)=>+a - +b)
  for (let i = 0; i < count; i++) {
    price += +all[i]
  }
  console.log(price)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));