#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  reverse(b, b + n);
  int kol = 0;
  int las = 0;
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += b[i];
  }
  cout << sum << endl;
  for (int i = 0; i < n; i++) {
    kol++;
    bool f = false;
    for (int j = 0; j < k; j++) {
      if (a[i] == b[j]) {
        f = true;
        b[j] = -1;
        break;
      }
    }
    if (f) {
      las++;
      if (las == k) {
        cout << kol + ((n - 1) - i);
        return 0;
      } else {
        cout << kol << " ";
        kol = 0;
      }
    }
  }
  return 0;
}
