#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k, c, j;
  cin >> n >> k;
  int a[n], i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sum = 0;
  for (j = 0; j < k; j++) {
    int x = a[0];
    int index = 0;
    for (i = 1; i < n; i++) {
      if (a[i] > x) {
        x = a[i];
        index = i;
      }
    }
    sum += x;
    a[index] = 0;
  }
  cout << sum << endl;
  if (k != 1) {
    c = 0;
    j = -1;
    for (i = 0; i < n; i++) {
      if (c < k - 1) {
        if (a[i] == 0) {
          cout << i - j << " ";
          c++;
          j = i;
        }
      }
    }
    cout << (n - 1 - j) << endl;
  } else {
    cout << n << endl;
  }
}
