#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

int main() {
    int n, k; cin >> n >> k;
    int vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    uint32_t sum = 0;
    for(int i = 0; i < k; i++) {
        sum += v[i];
    }
    cout << sum;
   
}