include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  vector<int> a(n);
  cin >> n >> k;
  rep(i, n) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int sum = 0;
  rep(i, k) {
    sum += a[i];
  }
  cout << sum;
  return 0;
}