#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K, tmp, count;
  vector<int> vec(1000);
  
  cin >> N >> K;

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (vec.at(i) > vec.at(j)) {
        tmp =  vec.at(i);
        vec.at(i) = vec.at(j);
        vec.at(j) = tmp;
      }
    }
  }
    
  count = 0;
  for (int k = 0; k < K; k++) {
    count += vec.at(k)
  }
  
  cout << count << endl;
}
