#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> p;
  int tmp;
  for(int i = 0;i<n;i++){
    cin >> tmp;
    p.push_back(tmp);
  }
  sort(p.begin(), p.end());//昇順
  int c= 0;
  
  for(int i = 0;i<k;i++){
    c+= p[i];
  }
  
  cout a<< c;
  
}