#include <bits/stdc++.h>
using namespace std;
struct node {
  int data, index;
};
bool cmp(const node& x, const node& y) { return x.data > y.data; }
int main() {
  int n, k;
  node a[3000];
  bool flag[3000] = {0};
  int b[3000];
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].data;
    b[i] = 1;
    a[i].index = i;
  }
  sort(a + 1, a + n + 1, cmp);
  long long sum = 0;
  for (int i = 1; i <= k; i++) {
    sum += a[i].data;
    flag[a[i].index] = 1;
  }
  cout << sum << endl;
  int j = 1;
  while (!flag[j]) {
    b[j + 1] += b[j];
    j++;
  }
  for (int i = j + 1; i <= n; i++) {
    if (flag[i]) {
      cout << b[i - 1] << ' ';
    } else {
      b[i] += b[i - 1];
    }
  }
  cout << b[n];
  cout << endl;
  return 0;
}
