#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const double EPS = 1e-9;
const int INF = 1 << 29;
int const NN = 1e6 + 6;
int a[NN];
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vv;
  map<int, int> mm;
  for (int i = 1; i <= n; ++i) cin >> a[i], vv.push_back(a[i]);
  sort(vv.begin(), vv.end());
  int ans = 0;
  for (int i = n - 1; i >= n - 1 - k + 1; --i) ans += vv[i], ++mm[vv[i]];
  cout << ans;
  putchar('\n');
  int cnt = 0;
  int need = k;
  for (int i = 1; i <= n; ++i) {
    ++cnt;
    if (mm[a[i]] > 0 && need > 1) {
      --mm[a[i]];
      cout << cnt;
      putchar(' ');
      cnt = 0;
      --need;
    }
  }
  if (cnt > 0) {
    cout << cnt;
  }
  putchar('\n');
  return 0;
}
