#include "iostream"
using namespace std;

int main()
{
    int n,k;
    cin >>n>>k;
    int a[n];
    for (int i=0; i<n; ++i){
        cin>>a[i];
    }
    int x = sizeof(a)/sizeof(a[0]);
    sort(a, a+x);
    int s = accumulate (begin(a), k(a)),0,plus<int>;
    cout<<s;
}
