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