#include <cstdio>
#include <algorithm>

int N, K;
int p[1005];
int ans;

int main() {
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; i++) scanf("%d", &p[i]);
  sort(p, p + N);
  for (int i = 0; i < K; i++) ans += p[i];
  printf("%d\n", ans);
  return 0;
}