#include <bits/stdc++.h>
using namespace std;
constexpr int R = 5e5 + 69, INF = 2e9 + 6969;
int qq;
int main() {
  int n, k, ans;
  int t[R];
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> t[i];
  }
  sort(t, t + n);
  for (int i = 0; i < k; ++i) {
    ans += t[i];
  }
  cout << ans;
  return 0;
}
