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