#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
    int N, K;
    cin >> N >> K;
    int p[1000];
    for (int i = 0; i < N; ++i)
    {
        cin >> p[i];
    }

    sort(p, p+N);

    int ans = 0;
    for (int i = 0; i < K; ++i)
    {
        ans += p[i];
    }

    cout << ans;
    
    return 0;
}
