
#include<bits/stdc++.h>
    using namespace std;
    #define int long long int
    #define pb push_back
    #define vi vector<int>
    #define loop(i,a,b) for(int i=a;i<b;i++)
    int32_t main()
    {
       
        #ifndef ONLINE_JUDGE
  freopen("input.txt" , "r" , stdin);
  freopen("output.txt" , "w" , stdout);
  #endif
           int n,k,s=0;
           cin>>n>>k
           int arr[n];
           loop(i,0,n)
           cin>>arr[i];
           sort(arr,arr+n);
           loop(i,0,k)
           s=s+arr[i];
           cout<<s<<endl;
    return 0;
}