#include<iostream>
#include<algorithm>
using namespace std;
int f[1010],n,k,sum;
int main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++) cin>>f[i];
	sort(f+1,f+n+1);
	for (int i=1;i<=k;i++) sum+=f[i];
	cout<<sum;
    return 0;
}
