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