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