#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, a[1000];
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> a[i];
  int n = N * sizeof(a[0]) / sizeof(a[0]);
  sort(a, a + n);
  int sum = 0;
  for (int i = 0; i < K; i++) sum += a[i];
  cout << sum << endl;
  return 0;
}
