#include <bits/stdc++.h>
using namespace std;
using namespace std;
const long long MAX = 100001;
void solve() {
  long long n;
  cin >> n;
  long long k;
  cin >> k;
  long long a[n];
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  long long sum = 0;
  for (long long i = 0; i < k; ++i) {
    sum += a[i];
  }
  cout << sum << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
