#include <bits/stdc++.h>

using namespace std;
#define ll longlong
int main()
{   ll n,k;cin>>n>>k;
     ll a[n];
 for(ll i=0;i<n;i++){
   cin>>a[i];
 }
 sort(a,a+n);
 ll ans=0;
 ll i=0;
 while(k>0){
   ans+=a[i];
   i++;
   k--;
 }
 cout<<ans<<endl;
 
 
}