#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<pair<int, int> > b;
  vector<int> d;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b.push_back(make_pair(a[i], i));
  }
  sort(b.begin(), b.end());
  int j = 0;
  while (j < k) {
    ans += b[b.size() - 1 - j].first;
    d.push_back(b[b.size() - 1 - j].second);
    j++;
  }
  sort(d.begin(), d.end());
  cout << ans << endl;
  j = 0;
  for (int i = 0; i < d.size() - 1; i++) {
    int y = 0;
    for (int u = j; u <= d[i]; u++) {
      y++;
    }
    cout << y << ' ';
    j = d[i] + 1;
  }
  int y = 0;
  for (int i = j; i < n; i++) {
    y++;
  }
  cout << y << endl;
  return 0;
}
