#include<bits/stdc++.h>
using namespace std;
#define ll long long 

int main()
{
	ll n,k,i;
	cin >> n >> k;
	ll a[n],s=0LL;
	for(i=0;i<n;i++)cin >> a[i];
	sort(a,a+n);
	for(i=0;i<k;i++)s+=a[i];
	cout << s;
}