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