#include <bits/stdc++.h>
int main() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> p(n);
  for (int i = 0; i < n; i++) {
    std::cin >> p[i];
  }
  int sum;
  int min, minnum;
  sum = 0;
  for (int l = 0; l < k; l++) {
    min = p[0];
    minnum = 0;
    for (int i = 0; i < n; i++) {
      if (p[i] < min) {
        min = p[i];
        minnum = i;
      }
    }
    sum = sum + min;
    p.erase(p.begin() + minnum);
  }
  std::cout << sum << std::endl;
}
