#include <bits/stdc++.h>
using namespace std;
const long long N = 2 * 1e5 + 5;
void solve() {
  long long n, k;
  cin >> n >> k;
  pair<long long, long long> p[n];
  for (long long i = 0; i < n; i++) {
    cin >> p[i].first;
    p[i].second = i + 1;
  }
  sort(p, p + n);
  long long tot = 0;
  vector<long long> ans;
  for (long long i = n - 1; i >= (n - k); i--) {
    tot += p[i].first;
    ans.push_back(p[i].second);
  }
  cout << tot << "\n";
  sort(ans.begin(), ans.end());
  long long x1 = 0, sz = ans.size();
  for (long long i = 0; i < sz - 1; i++) {
    cout << ans[i] - x1 << " ";
    x1 = ans[i];
  }
  cout << n - x1 << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) solve();
  return 0;
}
