#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
vector <int>a;
int n,k,i,j,sum=0;
cin>>n>>k;
for(i=0;i<n;i++){
        cin>>j;
    a.push_back(j);
}55
sort(a.begin(),a.end());
for(i=0;i<k;i++)
    sum+=a[i];
cout<<sum;

}
