#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
const int inf = 1000000000; // 10^9 Ten to the power of nine.
/**** Type Define ****/
 
    int main(){
       int n,K;
       cin>>n>>K;
       int a[1000];  int ans=0;

       for (int i = 0; i < n; i++)
       {
          cin>>a[i];
       }
       
       sort(a,a+n);//1000までsortしない

     
       for (int i = 0; i < k; i++)
       {
          ans +=a[i];
       }
       
         cout<<ans<<endl;
         return 0;}