#include <bits/stdc++.h>
using namespace std;
long long x, n, i, cmp, j, k, v, sum;
long long a[10000], b[10000], pos[10000];
int main() {
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  x = n + 1;
  for (i = 1; i <= k; i++) {
    x--;
    v = b[x];
    for (j = 1; j <= n; j++)
      if (a[j] == v) {
        cmp++;
        pos[cmp] = j;
        sum += a[j];
        a[j] = -1;
        break;
      }
  }
  sort(pos + 1, pos + 1 + cmp);
  cout << sum << "\n";
  x = 0;
  for (i = 1; i <= cmp; i++) {
    if (i == cmp)
      cout << n - x;
    else
      cout << pos[i] - x << " ";
    x = pos[i];
  }
  return 0;
}
