#include <bits/stdc++.h>
int main() {
  using namespace std;
  int n, k, sum = 0;
  cin >> n >> k;
  int ar[n + 5];
  for (int i = 0; i < n; i++) cin >> ar[i];
  sort(ar, ar + n);
  for (int i = 0; i < k; i++) sum += ar[i];
  cout << sum << endl;
  return 0;
}
