#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, p, sum = 0;
  vector<int> v;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p);
    v.push_back(p);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < k; i++) {
    sum += v[i];
  }
  printf("%d\n", sum);
}
