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