#include <bits/stdc++.h>
using namespace std;
bool rt(const pair<int, int>& a, const pair<int, int>& b) {
  return a.first > b.first;
}
bool r(const pair<int, int>& a, const pair<int, int>& b) {
  return a.second < b.second;
}
int main() {
  int n, k, i, x;
  cin >> n >> k;
  vector<pair<int, int>> v;
  for (i = 0; i < n; i++) {
    cin >> x;
    v.push_back(make_pair(x, i));
  }
  sort((v).begin(), (v).end(), rt);
  vector<int> vc;
  long long int sum = 0;
  for (i = 0; i < k; i++) {
    vc.push_back(v[i].second);
    sum += v[i].first;
  }
  cout << sum << endl;
  sort((vc).begin(), (vc).end());
  int j = 0;
  for (i = 0; i < k; i++) {
    if (i != k - 1) {
      cout << vc[i] - j + 1 << " ";
    } else {
      cout << n - j << " ";
    }
    j = vc[i] + 1;
  }
  return 0;
}
