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