#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
constexpr int MOD = 998244353;
constexpr int MAX = 510000;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  ll ret = 0;
  for (int i = 0; i < k; i++) ret += a[i];
  cout << ret << endl;
}
