#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
using namespace std;
using ll = long long;

signed main() {
    IO;
    // int tests = 1;
    // cin >> tests;
    // for(int test = 1; test <= tests; ++test) {
        
    // }
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
	int sum = 0;
	for(int i = 0; i < k; ++i) sum += a[i]
	cout << sum;
    return 0;
}