#include <bits/stdc++.h>
int main(void) {
  int size, reps;
  scanf("%d", &size);
  scanf("%d", &reps);
  int i = 0;
  int arr[size];
  while (i < size) {
    scanf("%d", &arr[i]);
    i++;
  }
  int sum = 0, min[reps], j = 0, l;
  printf("\n");
  for (i = 0; i < size; i++) {
    for (l = 0; l < i; l++) {
      if (arr[i] < arr[j]) {
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
      }
    }
  }
  j = 0;
  while (j != reps) {
    sum = arr[j] + sum;
    j++;
  }
  printf("%d", sum);
}
