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