#include <bits/stdc++.h>
using namespace std;
const int imax = numeric_limits<int>::max(), imin = numeric_limits<int>::min();
const long long lmax = numeric_limits<long long>::max(),
                lmin = numeric_limits<long long>::min();
bool Svd = 0;
void solve() {
  Svd = 1;
  int n, k;
  cin >> n >> k;
  pair<int, int> a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i + 1;
  }
  sort(a, a + n, greater<pair<int, int>>());
  int ans[k];
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += a[i].first;
    ans[i] = a[i].second;
  }
  cout << sum << endl;
  sort(ans, ans + k);
  int prog = 0;
  for (int i = 0; i < k; i++) {
    if (i != 0)
      cout << (i == k - 1 ? n : ans[i]) - ans[i - 1] << ' ';
    else
      cout << (k == 1 ? n : ans[i]) << ' ';
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  if (!Svd) cout << "solve() function blm dipanggil!" << endl;
  return 0;
}
