#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int K, N;
  scanf("%d%d", &N, &K);
  vector<int> vec(N);
  int num;
  for (int i = 0; i < N; i++) {
    scanf("%d", &num);
    vec[i] = num;
  }
  sort(vec.begin(), vec.end());
  int sum = 0;
  for (int i = 0; i < K; i++) {
    sum += vec[i];
  }
  printf("%d", sum);
  return 0;
}
