#include<iostream>
using namespace std;
int main()
{
  int n , k ;
  cin>> n >> k;
  vector<int> vec(n);
  for (int  i =0 ; i < n; i++ ) 
    cin>> vec[i];
  sort(vec.begin(), vec.end() ) ;
  long long sum = 0;
  for(int i = 0 ; i < k ; i++ ) sum += vec[i];
  cout <<sum;
  return 0;
}