#include <bits/stdc++.h>
using namespace std;
int a[2005];
int b[2005];
int mp[2005];
int main() {
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  long long ans = 0;
  for (int i = n - 1; i > n - 1 - k; i--) {
    ans += b[i];
    mp[b[i]]++;
  }
  cout << ans << endl;
  int t = 1;
  for (int i = 0; i < n; i++) {
    if (mp[a[i]] && k != 1) {
      cout << t << " ";
      t = 0;
      mp[a[i]]--;
      k--;
    } else if (k == 1) {
      cout << n - i << endl;
      break;
    }
    t++;
  }
}
