#include <bits/stdc++.h>
template <typename T>
std::string NumberToString(T Number) {
  std::ostringstream ss;
  ss << Number;
  return ss.str();
}
using namespace std;
int main() {
  int n, k;
  int ar[2205];
  scanf("%d %d", &n, &k);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &ar[i]);
  }
  sort(ar, ar + n);
  for (int i = 0; i < k; i++) {
    sum += ar[i];
  }
  printf("%d\n", sum);
  return 0;
}
