'use strict';

const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const foo = (str) => str.split(' ').map(v => parseInt(v, 10));

const numbers1 = foo(inputs[0]);
const numbers2 = foo(inputs[1]);

numbers2.sort((a, b) => a - b);

let price = 0;
for (let i = 0 ; i < numbers1[1] ; ++i) {
  price += numbers2[i];
}

console.log(price);