#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, arr[1100];
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
  sort(arr + 1, arr + 1 + n);
  int ans = 0;
  for (int i = 1; i <= k; i++) ans += arr[i];
  cout << ans << endl;
  return 0;
}
