#include <bits/stdc++.h>
unsigned ks[2009];
unsigned as[2009];
int indircmp(const void* a, const void* b) {
  return as[*(unsigned*)b] - as[*(unsigned*)a];
}
int cmp(const void* a, const void* b) { return *(unsigned*)a - *(unsigned*)b; }
int main() {
  unsigned i, n, k, max;
  scanf("%u%u", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%u", as + i);
    ks[i] = i;
  }
  qsort(ks, n, sizeof(unsigned), indircmp);
  qsort(ks, k, sizeof(unsigned), cmp);
  max = 0;
  for (i = 0; i < k; i++) max += as[ks[i]];
  printf("%u\n", max);
  ks[0] = 0;
  for (i = 1; i < k; i++) {
    printf("%u ", ks[i] - ks[i - 1]);
  }
  printf("%u", n - ks[k - 1]);
  return 0;
}
