#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const long long MOD7 = 1e9 + 7;
struct Node {
  int score;
  int idx;
} node[MAXN];
int n;
int cmp(Node a, Node b) { return a.score > b.score; }
int ans[MAXN];
int K;
void work() {
  sort(node + 1, node + 1 + n, cmp);
  int res = 0;
  for (int i = 1; i <= K; ++i) {
    res += node[i].score;
    ans[i] = node[i].idx;
  }
  printf("%d\n", res);
  if (K == 1) {
    printf("%d\n", n);
    return;
  }
  sort(ans + 1, ans + 1 + K);
  printf("%d", ans[1]);
  for (int i = 2; i <= K - 1; ++i) {
    printf(" %d", ans[i] - ans[i - 1]);
  }
  printf(" %d\n", n - ans[K - 1]);
}
int main() {
  scanf("%d%d", &n, &K);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &node[i].score);
    node[i].idx = i;
  }
  work();
  return 0;
}
