function Main(input) {
  input = input.split('\n');
  const [n, k] = input[0].split(' ').map(Number);
  const p = input[1].split(' ').map(Number).sort((a, b) => a - b);
  let sum = 0;
  for (let i = 0; i < k; i++) {
    sum += p[i];
  }
  console.log(sum);
}

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