#include <bits/stdc++.h>
using namespace std;
int ans[100100];
pair<int, int> v[100100];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  int cont = 0;
  for (int i = 1; i <= n; i++) {
    int nr;
    cin >> nr;
    v[i] = {nr, i};
  }
  sort(v + 1, v + n + 1);
  reverse(v + 1, v + n + 1);
  for (int i = 1; i <= k; i++) {
    cont += v[i].first;
    ans[i] = v[i].second;
  }
  sort(ans + 1, ans + k + 1);
  cout << cont << '\n';
  int last = 0;
  ans[k] = n;
  for (int i = 1; i <= k; i++) {
    cout << ans[i] - last << " ";
    last = ans[i];
  }
  return 0;
}
