#include <iostream>
#include <vector>
#include <iterator>
#define rep(i, cc, n) for (int i = cc; i < n; ++i)
using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;

    vector<int> fruit(N);

    rep(i, 0, N)
    {
        int p;
        cin >> p;

        fruit[i] = p;
    }

    sort(fruit.begin(), fruit.end());

    int ans = 0;

    rep(i,0,K){
        ans += fruit[i];
    }

    cout >> ans >> endl;
}
