#include <bits/stdc++.h>
int main() {
  int N, K, i = 0, k = 0, l = 0, ans = 0;
  int s[1000];
  scanf("%d%d", &N, &K);
  for (i; i < N; i++) {
    scanf("%d", &s[i]);
  }
  while (k < N) {
    for (int j = 1; s[j] != '\0'; j++) {
      if (s[j] < s[j - 1]) {
        int T = s[j];
        s[j] = s[j - 1];
        s[j - 1] = T;
      }
    }
    k++;
  }
  for (l; l < K; l++) {
    ans += s[l];
  }
  printf("%d", ans);
  return 0;
}
