const main = (input) => {
  const [a, b] = input.trim().split('\n')
  const [, K] = a.split(' ').map(v => Number(v))
  const prices = b.split(' ').map(v => parseInt(v, 10)).sort((a, b) => a - b)

  return console.log(prices.slice(0, K).reduce((a,b) => a + b, 0))
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))