#include <bits/stdc++.h>
int main(void) {
  int n, k, i, j, tmp;
  scanf("%d %d", &n, &k);
  int number[n - 1];
  for (i = 0; i < n; i++) {
    scanf("%d", &number[i]);
  }
  for (i = 0; i < n; ++i) {
    for (j = i + 1; j < n; ++j) {
      if (number[i] > number[j]) {
        tmp = number[i];
        number[i] = number[j];
        number[j] = tmp;
      }
    }
  }
  int sum = 0;
  for (i = 0; i < k; i++) {
    sum += number[i];
  }
  printf("%d\n", sum);
  return 0;
}
