#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> ans(n);
  long long x;
  for (long long i = 1; i <= n; i++) cin >> x, ans.push_back(x);
  sort(ans.begin(), ans.end());
  long long now = 0;
  for (long long i = 0; i < k; i++) now += ans[i];
  cout << now;
  return 0;
}
