#include <bits/stdc++.h>
using namespace std;
int main() {
  int cs[2005], paixu[2005];
  int n;
  cin >> n;
  int k;
  cin >> k;
  for (int i = 0; i < n; i++) {
    cin >> cs[i];
    paixu[i] = cs[i];
  }
  sort(paixu, paixu + n);
  int maxs[2005];
  int tishu[2005];
  for (int j = n - 1, i = 0; i < k; i++, j--) {
    maxs[i] = paixu[j];
  }
  int ans = 0;
  for (int j = 0; j < k; j++) {
    ans += maxs[j];
  }
  cout << ans << endl;
  int count = 0, mjishu = 0;
  bool mj = true;
  for (int i = 0; i < n; i++) {
    mj = true;
    for (int j = 0; j < k; j++) {
      if (cs[i] == maxs[j]) {
        mj = false;
        mjishu++;
        maxs[j] = 0;
        if (mjishu != k) {
          count++;
          cout << count << " ";
          count = 0;
          break;
        } else {
          for (; i < n + 5; i++) {
            if (cs[i] != 0) {
              count++;
            } else {
              cout << count << endl;
              return 0;
            }
          }
        }
      }
    }
    if (mj) count++;
  }
}
