#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  int price[150];
  cin >> N >> K;
  int minp = 0;
  for (int i = 0; i < N; i++) {
    cin >> price[i];
  }
  sort(price, price + N);
  for (int j = 0; j < K; j++) {
    minp = price[j] + minp;
  }
  cout << minp << endl;
  return 0;
}
