#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
void write(int x) {
  if (x < 0) x = -x, putchar('0');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  return;
}
int n, a[2222], k, ans;
int main() {
  n = read();
  k = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= k; i++) ans += a[i];
  write(ans);
  return 0;
}
