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