#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
void print(vector<T>& v, bool spaced = true) {
  int n = v.size();
  string space = (spaced ? " " : "");
  for (int i = 0; i < n; ++i) {
    cout << v[i] << space;
  }
  cout << '\n';
}
template <class T>
T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  sort((v).begin(), (v).end());
  int ans = 0;
  for (int i = 0; i < k; ++i) ans += v[i];
  cout << ans << '\n';
  return 0;
}
