#include<bits/stdc++.h>

using namespace std;

int main(){
    int N;
    int K;
    int p[N] = {};
    int ans =0;

    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> p[i];
    }

    int size = sizeof(p)/sizeof(a[0]);
    sort(p,p+size);

    for (int i=0;i<K;i++){
        ans +=p[i];
    }

    cout << ans << endl;

}
