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