#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d", &n);
  ;
  scanf("%d", &k);
  ;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &v[i]);
    ;
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = 0; i < k; ++i) {
    ans += v[i];
  }
  printf("%d\n", ans);
  return 0;
}
