#include <bits/stdc++.h>
using namespace std;
int main() {
  int price[1000], i, n, k, sum = 0;
  cin >> n >> k;
  for (int(i) = 0; i < int(n); i++) cin >> price[i];
  sort(price, price + n);
  for (int(i) = 0; i < int(k); i++) sum += price[i];
  cout << sum;
  return 0;
}
