#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > a(n);
  vector<int> p(k);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.rbegin(), a.rend());
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += a[i].first;
    p[i] = a[i].second;
  }
  sort(p.begin(), p.end());
  cout << ans << endl;
  int now = -1;
  for (int i = 0; i < k; i++) {
    if (i == k - 1) {
      cout << n - now - 1 << ' ';
    } else {
      cout << p[i] - now << ' ';
      now = p[i];
    }
  }
  return 0;
}
