#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
int n, k;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> k;
  vector<int> v, a, b;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
    a.push_back(x);
  }
  sort(a.rbegin(), a.rend());
  int ans = 0, cntr = 1;
  for (int i = 0; i < k; i++) {
    ans += a[i];
    b.push_back(a[i]);
  }
  cout << ans << endl;
  int d = 0, c = 0;
  for (int i = 0; i < n; i++) {
    auto f = find(b.begin(), b.end(), v[i]);
    if (f == b.end())
      cntr++;
    else {
      d++;
      if (d == k) break;
      cout << cntr << " ";
      c += cntr;
      cntr = 1;
      b.erase(f);
    }
  }
  cout << n - c << endl;
  return 0;
}
