#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			#endif

			ll n,k;
			cin>>n>>k;
			ll ans=0;
			ll arr[n];
			for(ll i=0;i<n;i++)
			cin>>arr[i];

			sort(arr,arr+n);
			for(ll i=0;i<k;i++)
			ans+=arr[i];
			cout<<ans;
			
			return 0;
		 }	
