#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> v;
  for (long long i = 0; i < n; ++i) cin >> v[i];
  sort(v.begin(), v.end());
  long long ans = 0;
  for (long long i = 0; i < k; ++i) ans += v[i];
  cout << ans;
  return 0;
}
