#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  int N;
  int K;
  cin >> N >> K;
  vector<int> v;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(),v.end());
  int sum = 0;
  for(int i=0;i<K;i++){
    sum += v[i];
  }
  cout << sum << endl;
  for()
}