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