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