#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int p[n];
  for (int k = 0; k < (n); k++) cin >> (p)[k];
  sort(p, p + n);
  int sum = 0;
  for (long long int i = 0; i < (k); i++) sum += p[i];
  return 0;
}
