#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> p;
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    int price;
    cin >> price;
    p.push_back(price);
  }
  std::sort(p.begin(), p.end());
  int sum = 0;
  for (int i = 0; i < K; ++i) {
    sum += p[i];
  }
  cout << sum << endl;
  return 0;
}
