#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k;
  	cin >> n >> k;
  	
   	vector<int> prices;
  	for(int i = 0; i < n; i++){
    	int a;
      	cin >> a;
      	prices.push_back(a);
    }
  
  	sort(prices.begin(), prices.end())
    int total = 0;
  	for(int i = 0; i < k; i++){
    	total += prices[i];
    }
  
  	cout << total;
}