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