#include <bits/stdc++.h>

using namespace std;

vector<int> bestCut;
int memo[1001];

int solve(int n, vector<int> &prices)
{
   if (n == 0)
      return 0;
   if (memo[n] != -1)
      return memo[n];

   bestCut[n] = n;
   int currentMax = prices[n];
   for (int i = n / 2; i >= 1; i--)
   {
      int bestForRemaining = solve(n - i, prices);
      if (currentMax < prices[i] + bestForRemaining)
      {
         currentMax = prices[i] + bestForRemaining;
         bestCut[n] = i;
      }
   }
   return memo[n] = currentMax;
}

int main()
{
   int n;
   cin >> n;
   bestCut.resize(n + 1);
   vector<int> prices(n + 1);
   memset(memo, -1, sizeof(memo));
   for (int i = 1; i <= n; i++)
   {
      cin >> prices[i];
   }

   auto s = solve(n, prices);
   cout << s << endl;
   int size = n;
   while (size != 0)
   {
      if (size != n)
         cout << " ";
      cout << bestCut[size];
      size = size - bestCut[size];
   }
   cout << endl;

   return 0;
}