#include <iostream>
#include <algorithm>

using namespace std;

int n,k,t[1005],sm,i;

int main() {
    cin>>n>>k;
    for (i=1; i<=n; i++) cin>>t[i];
    sort(t+1,t+n+1);
    for (i=1; i<=k; i++) sm+=t[i];
    cout<<sm;
}