#include <bits/stdc++.h>
void sort(int *p, int n);
int main(void) {
  int n, k, p[1000], i;
  int x = 0;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  sort(p, n);
  for (i = 0; i < k; i++) {
    x = x + p[i];
  }
  printf("%d\n", x);
  return 0;
}
void sort(int *p, int n) {
  int i, j, index, min;
  for (i = 0; i < n - 1; i++) {
    index = i;
    min = p[i];
    for (j = 1; j < n; j++) {
      if (min > p[i]) {
        index = j;
        min = p[j];
      }
    }
    p[index] = p[i];
    p[i] = min;
  }
}
