#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j = 0, n, k;
  cin >> n >> k;
  vector<int> v;
  for (int in = 0; in < n; in++) {
    cin >> i;
    v.push_back(i);
  }
  sort(v.begin(), v.end());
  for (int in = 0; in < k; in++) j += v[in];
  cout << j << endl;
  return 0;
}
