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

int main()
{
	int n, k, count = 0;
	int s[1005] = { 0 };

	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> s[i];

	sort(s, s + n);
	for (int i = 0; i < k; i++)
		count += s[i];

	cout << count << endl;

	return 0;
}