#include<iostream>
#include<vector>
#include<algorithm>
int main() 
{
	int n, k;
	int sum = 0;
	cin >> n >> k;
	vector<int>p(n);
	for (int i = 0;i < n;i++) {
		cin >> p;
	}
	sort(p.begin(), p.end());
	for (int i = 0; i < k;i++) {
		sum = sum + p[i];
	}
	cout << sum<<endl;

}