#include <iostream>
#include <algorithm>
using namespace std;
long long n,k,s,a[1000],i;
int main()
{
	cin >> n >> k;
	for ( i = 0 ; i < n ; i++ ) cin >> a[i];
	sort(a,a+n);
	for ( i = 0 ; i < k ; i++ ) s+=a[i];
	cout << s;
}