#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int32_t main() {
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  vector<long long> arr(n);
  for (long long x : arr) {
    cin >> x;
  }
  sort(arr.begin(), arr.end());
  long long ans = 0;
  for (long long i = 0; i < (long long)k; ++i) {
    ans += arr[i];
  }
  cout << ans << '\n';
  return 0;
}
