#include <bits/stdc++.h>
using namespace std;
int n, k, a[2010], b[2010];
pair<int, int> idx[2010];
set<int> s;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &a[i]);
    idx[i] = {a[i], i};
  }
  sort(idx, idx + n);
  int cnt = k, t = n - 1, ans = 0;
  while (cnt--) {
    ans += idx[t].first;
    s.insert(idx[t--].second);
  }
  int i = 0, prevv = 0;
  cout << ans << endl;
  for (auto z : s) {
    i++;
    if (i == k) {
      int b = z + 1 - prevv + (n - z - 1);
      cout << b;
      return 0;
    }
    cout << z + 1 - prevv << " ";
    prevv = z + 1;
  }
  return 0;
}
