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