#include <bits/stdc++.h>
int comp(const void* a, const void* b) { return (*(int*)a - *(int*)b); }
int main() {
  int n, p[1010], k, soma = 0;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  for (int j = 0; j < k; j++) {
    soma += p[j];
  }
  printf("%d\n", soma);
  qsort(p, n, sizeof(int), comp);
  return 0;
}
