#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 3e5 + 9;
const ll inf = 1e9 + 7;
typedef pair<ll,ll> LL;

ll n,k,sum,a[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n>>k;
    for (i = 1;i <= n;i++) cin>>a[i];
    sort(a + 1,a + n + 1);
    for (i = 1;i <= k;i++) sum += a[i];
    cout<<sum;
}
