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