using namespace std;
#include <iostream>
#include <algorithm>

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