#include <bits/stdc++.h>
using namespace std;
int tasks[2010];
bool cmp(int i, int j) { return (tasks[i] > tasks[j]); }
int main() {
  int days, n_tasks;
  cin >> n_tasks >> days;
  vector<int> indices(n_tasks);
  for (int i = 0; i < n_tasks; i++) {
    cin >> tasks[i];
    indices[i] = i;
  }
  sort(indices.begin(), indices.end(), cmp);
  sort(indices.begin(), indices.begin() + days);
  int total_sum = 0;
  for (int i = 0; i < days; i++) {
    total_sum += tasks[indices[i]];
  }
  cout << total_sum << endl;
  int tasks_done = 0;
  for (int i = 1; i < days; i++) {
    cout << indices[i] - tasks_done << ' ';
    tasks_done = indices[i];
  }
  cout << n_tasks - tasks_done << endl;
  return 0;
}
