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