#include <bits/stdc++.h>

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

	vector<int> vi;

	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		vi.push_back(p);
	}

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

	int sum = 0;

	for (int i = 0; i < K; i++) {
		sum += vi[i];
	}

	cout << sum;
}
