#include <bits/stdc++.h>
using namespace std;
void test_case() {
  long long n, k, temp = 0;
  cin >> n >> k;
  vector<long long> p;
  for (int i = 0; i < n; ++i) {
    cin >> temp;
    p.push_back(temp);
  }
  sort(p.begin(), p.end());
  long long s = 0;
  for (int i = 0; i < k; ++i) {
    s += p[i];
  }
  cout << s;
}
int main() {
  test_case();
  return 0;
}
