#include <bits/stdc++.h>
int main() {
  int n, k, N[2300], i;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &N[i]);
  }
  int p = 1, s = 0, min, a;
  while (p <= k) {
    min = N[0];
    a = 0;
    for (i = 1; i < n; i++) {
      if (min > N[i]) {
        min = N[i];
        a = i;
      }
    }
    s = s + min;
    N[a] = 100000;
    p++;
  }
  printf("%d", s);
}
