#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  pair<int, int> a[2005];
  for (int i = 0; i < n; i++) {
    int first;
    scanf("%d", &first);
    a[i] = make_pair((first), (i));
  }
  sort(a, a + n);
  reverse(a, a + n);
  int tot = 0;
  vector<int> v;
  for (int i = 0; i < k; i++) {
    tot += a[i].first;
    v.push_back(a[i].second);
  }
  sort(v.begin(), v.end());
  v.pop_back();
  v.push_back(n - 1);
  int last = -1;
  printf("%d\n", tot);
  for (auto it : v) {
    printf("%d ", it - last);
    last = it;
  }
}
