#include <bits/stdc++.h>
int main(void) {
  int i, j, n_fruit, k_fruit, price, fruit[1001], temp;
  scanf("%d%d", &n_fruit, &k_fruit);
  for (i = 0; i < n_fruit; i++) {
    scanf("%d", &fruit[i]);
  }
  for (i = 0; i < n_fruit; i++) {
    for (j = i + 1; j < n_fruit; j++) {
      if (fruit[i] > fruit[j]) {
        temp = fruit[i];
        fruit[i] = fruit[j];
        fruit[j] = temp;
      }
    }
  }
  for (i = 0; i < k_fruit; i++) {
    price += fruit[i];
  }
  printf("%d\n", price);
  return 0;
}
