#include <bits/stdc++.h>
int main() {
  int i, s = 0, j, t, a[1001000];
  int k, n;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++)
    for (j = i; j < i; j++)
      if (a[i] > a[j]) {
        t = a[i];
        a[i] = a[j];
        a[j] = t;
      }
  for (i = 0; i < k; i++) s = s + a[i];
  printf("%d", s);
  return 0;
}
