#include <bits/stdc++.h>
using namespace std;
const long long nax = 1e9 + 7;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += a[i];
  }
  cout << ans;
}
int main() {
  freopen("input.txt", "r", stdin);
  ;
  solve();
  return 0;
}
