#include <bits/stdc++.h>
using namespace std;
int a[2500], sum;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &(a[i]));
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= k; i++) {
    sum += a[i];
  }
  printf("%d\n", sum);
}
