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