#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, k, p = 0, x;
  cin >> n >> k;
  pair<int, int> a[n];
  for (i = 0; i < n; i++) cin >> a[i].first, a[i].second = i;
  sort(a, a + n);
  int b[k];
  for (i = n - 1; i >= n - k; i--)
    p += a[i].first, b[n - 1 - i] = a[i].second + 1;
  sort(b, b + k);
  b[k - 1] = n;
  cout << p << "\n" << b[0] << " ";
  for (i = 1; i < k; i++) cout << b[i] - b[i - 1] << " ";
  return 0;
}
