#include<iostream>
using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<int> flutes(N);
  for(int i = 0; i < N; i++){
    cin >> flutes[i];
  }
  
  sort(flutes.begin(), flutes.end());
  int ans = 0;
  for(int i = 0; i < K; i++){
    ans += flutes[i];
  }
  
  cout << ans << endl;
  return 0;
}