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