#include <bits/stdc++.h>
#include <math.h>//pow(x,y)=x^y
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(i,n) for (int i=0; i <(n);i++)
#define ll long long
using namespace std;


int main() {
int N,K,sum;
sum = 0;
vector<int> A(N);
cin >> N >> K;
rep(i,N){
    cin >> A.at(i);
}
sort(A.begin(),A.end());

rep(i,K){
sum += A.at(i);
}
cout << sum << endl;

}
