#include <bits/stdc++.h>
using namespace std;
int n, k;
pair<int, int> a[2005];
int b[2005];
int sum;
bool cmp(pair<int, int> g, pair<int, int> h) { return g.first > h.first; }
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int tem;
    cin >> tem;
    a[i] = make_pair(tem, i);
  }
  sort(a, a + n, cmp);
  sum = 0;
  memset(b, 0, sizeof(b));
  for (int i = 0; i < k; i++) {
    sum += a[i].first;
    b[a[i].second] = 1;
  }
  cout << sum << endl;
  int fi = -1;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] == 1 && cnt < (k - 1)) {
      int lon = i - fi;
      fi = i;
      cout << lon << " ";
      cnt++;
    }
  }
  cout << (n - 1) - fi << endl;
  return 0;
}
