#include <bits/stdc++.h>
template <class T>
inline void read(T &x) {
  x = 0;
  int f = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    f |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  x = f ? -x : x;
  return;
}
int a[2220];
int n, k, ans;
int main() {
  read(n), read(k);
  for (int i = 1; i <= n; ++i) read(a[i]);
  std::sort(a + 1, a + n + 1);
  for (int i = 1; i <= k; ++i) ans += a[i];
  printf("%d\n", ans);
  return 0;
}
