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