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