#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (auto& x : v) cin >> x;
  sort(v.begin(), b.end());
  int ans = 0;
  for (int i = 0; i < k; i++) ans += v[i];
  cout << ans << endl;
}