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