#include "bits/stdc++.h"
using namespace std;

const int N=1e5+20;

int n,k,a[N];

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);

	sort(a,a+n);
	printf("%d",accumulate(a,a+k,0));
}