#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;
int main() {
  int n, k;
  cin >> n >> k;
  vec a(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans;
  for (int j = 0; j < (int)(k); j++) {
    ans += a[j];
  }
  cout << ans;
}
