#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<ld, ld>;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
const int MIN = 2e5 + 20;
const int MAX = 1e9 + 20;
pair<ll, ll> p[MIN];
ll n, i, q, k, sum, m, t[MIN], b[MIN], x, y, l, r, f;
int main() {
  int n, k, m, sum = 0;
  cin >> n >> k;
  for (i = (0); i <= (n); i++) {
    cin >> p[i].first;
    p[i].second = i + 1;
  }
  sort(p, p + n);
  l = 1;
  for (i = (n - k); i <= (n - 1); i++) {
    sum += p[i].first;
    t[l] = p[i].second;
    l++;
  }
  cout << sum << "\n";
  sort(t, t + k + 1);
  for (i = (1); i <= (k - 1); i++) {
    cout << t[i] - t[i - 1] << " ";
  }
  cout << n - t[k - 1];
  return 0;
}
