#include<bits/stdc++.h>
using namespace std;
#define    nl     "\n"
#define    End    return 0
#define    gt     greater<int>()
#define    ll     long long int

int main()
{
    int n,m;
    ll s=0;
    cin>>n>>m;
    int a[n];
    for0(i,n)cin>>a[i];
    sort(a,a+n);
    for0(i,m){
        s+=a[i];
    }
    cout<<s;
}
