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