#include <bits/stdc++.h>
void quick_sort(int *ary, int begin, int end) {
  int i, j, work, pivot;
  pivot = ary[(begin + end) / 2];
  i = begin;
  j = end;
  while (1) {
    while (ary[i] < pivot) ++i;
    while (ary[j] > pivot) --j;
    if (i >= j) break;
    work = ary[i];
    ary[i] = ary[j];
    ary[j] = work;
    i++;
    j--;
  }
  if (begin < i - 1) quick_sort(ary, begin, i - 1);
  if (j + 1 < end) quick_sort(ary, j + 1, end);
}
int main() {
  int n, k, i, sum = 0;
  scanf("%d %d", &n, &k);
  int a[n];
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  quick_sort(a, 0, k - 1);
  for (i = 0; i < k; i++) sum += a[i];
  printf("%d", sum);
}
