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

int main()
{
    ll n, k
    cin >> n >> k;
    ll arr[n];
    for(int i = 0; i <n; i++)   {
        cin >> a[i];
    }
    sort(arr, arr+n);
    ll sum  = 0;
    for(int i = 0; i < k; i++)  {
        sum += arr[i];
    }
    cout << sum;
    return 0;
}
