#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.rbegin(), a.rend());
  vector<int> in;
  long long sum = 0;
  for (int i = 0; i < k; i++) {
    in.push_back(a[i].second);
    sum += a[i].first;
  }
  cout << sum << endl;
  sort(in.begin(), in.end());
  int cnt = 0;
  for (int i = 0; i < k; i++) {
    if (i + 1 == k) {
      cout << n - cnt << " ";
      return 0;
    }
    cout << in[i] + 1 - cnt << " ";
    cnt = in[i] + 1;
  }
  return 0;
}
