#include <iostream>
#include <algorithm>
#define FOR(a,b) for(int a =0 ; a < int c ;a++)
using namespace std;
int main()
{
  int price[1000],i,n,k,sum=0;
  cin>>n >>k;
  
  FOR(i,n)
    cin>>price[i];
  
  sort(price,price+n);
  
  FOR(i,k)
    sum += price[i];
  
  cout<<sum<<"\n";
  
  return 0;
  
}