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