#include <bits/stdc++.h>
int main(void) {
  int N, K;
  int *p;
  int i, j, atoi;
  scanf("%d %d", &N, &K);
  printf("%d,%d\n", N, K);
  p = (int *)malloc(N * sizeof(char));
  for (i = 0; i < N; i++) scanf("%d", &p[i]);
  for (i = 0; i < N - 1; i++) {
    for (j = 0; j < N - i - 1; j++) {
      if (p[j] > p[j + 1]) {
        atoi = p[j];
        p[j] = p[j + 1];
        p[j + 1] = atoi;
      }
    }
  }
  int sum = 0;
  for (i = 0; i < K; i++) sum += p[i];
  printf("%d\n", sum);
  return 0;
}
