#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  vector<int> arrNums;
  int iTemp, nNeed, nNum, i;
  long long iSum = 0;
  cin >> nNum >> nNeed;
  while (nNum--) {
    cin >> iTemp;
    arrNums.push_back(iTemp);
  }
  sort(arrNums.begin(), arrNums.end());
  for (i = 0; i < nNeed; ++i) {
    iSum += arrNums[i];
  }
  cout << iSum;
endapp:
  return 0;
}
