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