#include <bits/stdc++.h>
using namespace std;
int level[2007];
int pos[2007];
int n, k, sum;
map<int, int> res;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &level[i]);
    pos[i] = level[i];
  }
  sort(level, level + n);
  for (int i = n - k; i < n; i++) {
    sum += level[i];
    res[level[i]]++;
  }
  printf("%d\n", sum);
  int c = 0;
  for (int i = 0; i < n; i++) {
    c++;
    int low = res[pos[i]];
    if (low) {
      k--;
      if (!k) {
        c += n - i - 1;
        break;
      }
      printf("%d ", c);
      c = 0;
      res[pos[i]]--;
    }
  }
  printf("%d ", c);
  return 0;
}
