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