#include <bits/stdc++.h>
using namespace std;
bool vis[100009];
int main() {
  int n, k;
  int a[100009], b[100009], c[10009], d[10009];
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  int s = 0;
  for (int i = 0, o = 1; i <= k; i++, o++) {
    c[o] = b[n - i];
  }
  for (int i = 1, x = 1; i <= k; i++, x++) {
    s = s + c[i];
    for (int j = 1; j <= n; j++) {
      if (c[i] == a[j]) {
        d[x] = j;
        a[j] = 0;
        vis[d[x]] = true;
        break;
      }
    }
  }
  int la;
  cout << s << endl;
  for (int i = n; i >= 1; i--) {
    if (vis[i]) {
      la = i;
      break;
    }
  }
  if (k == 1)
    cout << n;
  else {
    int f = 0;
    for (int i = 1; i < la; i++) {
      if (vis[i]) {
        cout << i - f << " ";
        f = i;
      }
    }
    cout << (la - f) + (n - la);
  }
  return 0;
}
