#include<cstdio>
#define maxn 1005
using namespace std;
bool cmp(int x,int y)
{
	return x<y;
}
int main(void)
{
	int n,k;
	int a[maxn];
	while(~scanf("%d%d",&n,&k))
	{
		for(int i=0;i<n;++i)
			scanf("%d",&a[i]);
			sort(a,a+n,cmp);
		int sum=0;
		for(int i=0;i<k;++i)
		sum+=a[i];
		printf("%d\n",sum);
	}
	return 0;
}