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