#include <bits/stdc++.h>
using namespace std;
int n, m, ok = 0, sum = 0;
struct node {
  int x;
  int num;
};
node a[2002];
bool cmp1(node a, node b) { return a.x > b.x; }
bool cmp2(node a, node b) { return a.num < b.num; }
int main() {
  int i, j, k;
  cin >> n >> k;
  a[0].num = 0;
  for (i = 1; i <= n; i++) {
    cin >> a[i].x;
    a[i].num = i;
  }
  sort(a + 1, a + n + 1, cmp1);
  sort(a + 1, a + k + 1, cmp2);
  for (i = 1; i <= k; i++) sum += a[i].x;
  cout << sum << endl;
  a[k + 1].num = k + 1;
  for (i = 1; i <= k - 1; i++) cout << a[i].num - a[i - 1].num << ' ';
  cout << n - a[k - 1].num;
  return 0;
}
