#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v;
  int a, b, c;
  cin >> a >> b;
  for (int i = 0; i < a; ++i) {
    cin >> c;
    v.push_back(c);
  }
  sort(v.begin(), v.end());
  int sum = 0;
  for (int i = 0; i < b; ++i) {
    sum = sum + v[i];
  }
  cout << sum << endl;
  return 0;
}
