#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < (n); i++) cin >> p[i];
  vector<int> m, x = p;
  for (int i = 0; i < k; i++) {
    int a = x[0], b = 0;
    if (x[i] < a) {
      a = x[i];
      b = i;
    }
    m.push_back(a);
    x.erase(std::remove(x.begin(), x.end(), x[b]), x.end());
  }
  int sum = 0;
  for (int i = 0; i < k; i++) sum += m[i];
  cout << sum << endl;
  return 0;
}
