#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, r = 1, l = 1, k, j, x, y, z, n, m, sum = 0, sum1 = 0,
                   sum2 = 0, sum3 = 0, sum4 = 0, flag1 = 0, flag2 = 0,
                   flag3 = 0, flag4 = 0, flag = 0, len = 0;
  scanf("%lld %lld", &n, &k);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  for (int i = 0; i < k; i++) {
    sum += a[i];
  }
  printf("%lld", sum);
  return 0;
}
