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