#include<iostream>
#include<vector>
int main(){
   int N,K;
   std::cin >> N >> K;
   int p[N];
   int ptmp;
  for (int i =0;i< N; i++)
  {
    std::cin >> ptmp;
    p[i] = ptmp;
  }
  
  std::sort(p.begin(),p.end());
  int sum = 0;
  for (int j = 0; j < K; j++){
      sum += p[j];
  }
  std::cout << sum;
  
}