#include <iostream>
#include <vector>
#include <algorithm>
#define INF 10000000001
using namespace std;
 
int main(){
  	
  	cin.sync_with_stdio(false);
  	cin.tie(NULL);
  
  	int n, k;;
  	cin >> n;
  	vector<uint_64> v;
	cin >> k;
  	for(int i = 0; i < n; ++i){
    	cin >> v[i];
    }
  	
  	uint_64 cnt = 0;
  	for(int i = 0; i < k; ++i){
    	uint_64 min_pos = 0, min_val = INF;
        for(int j = 0; j < n; ++j){
        	if(v[j] < min_val){
            	min_val = v[j];
              	min_pos = j;
            }
        }
      	cnt += min_val;
      	v[min_pos] = INF;
    }
  	cout << cnt << endl;
}