#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, t, b, d, i, g, h = 0, k, j, f;
  cin >> n;
  cin >> k;
  vector<int> a;
  vector<int> c;
  vector<int> e;
  vector<int> x;
  for (i = 0; i < n; i++) {
    cin >> b;
    a.push_back(b);
    c.push_back(b);
  }
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  for (i = 0; i < k; i++) {
    h = h + c[i];
    x.push_back(c[i]);
  }
  f = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < k; j++) {
      if (a[i] == x[j]) {
        e.push_back(i + 1);
        x[j] = -8;
        d = n - i - 1;
        break;
      }
    }
  }
  e[e.size() - 1] = e[e.size() - 1] + d;
  cout << h << endl;
  for (i = 0; i < e.size(); i++) {
    cout << e[i] - f << " ";
    f = e[i];
  }
  return 0;
}
