#include <bits/stdc++.h>
using namespace std;
bool cmp(const pair<long long, long long>& a,
         const pair<long long, long long>& b) {
  return a.first > b.first;
}
bool cmp1(const pair<long long, long long>& a,
          const pair<long long, long long>& b) {
  return a.second < b.second;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, k, ans = 0, i, ara[10000];
  vector<pair<long long, long long>> v, v1;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> ara[i];
    v.push_back({ara[i], i + 1});
  }
  sort(v.begin(), v.end(), cmp);
  for (i = 0; i < k; i++) {
    ans += v[i].first;
    v1.push_back({v[i].first, v[i].second});
  }
  cout << ans << endl;
  sort(v1.begin(), v1.end(), cmp1);
  long long pos = 0;
  for (i = 0; i < k - 1; i++) {
    cout << v1[i].second - pos << " ";
    pos = v1[i].second;
  }
  cout << n - pos << endl;
  return 0;
}
