#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"

void solve()
{
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(auto &x:v)cin>>x;
    sort(v.begin(),v.end());
    ll sum=0;
    for(int i=0;i<k;i++){
        sum+=c[i];
    }
    cout<<sum;
}

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}