#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> s;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    s.push_back(x);
  }
  if (k == 1) {
    cout << *min_element(s.begin(), s.end()) << endl;
    return 0;
  }
  partial_sort(s.begin(), s.begin() + k + 1, s.end());
  int ans = 0;
  for (int i = 0; i < k; ++i) {
    ans += s[i];
  }
  cout << ans << endl;
}
