#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1010;
LL a[L];
LL dp[L];
int t[L];
int N;
int main() {
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	LL r=a[0]-1;
	LL p=0;
	for(int i=N-1;i>=0;i--){
		dp[i]=a[i];
		for(int k=2;i+k<N;k+=2){
			if(dp[i]<a[i]+dp[i+k]){
				dp[i]=a[i]+dp[i+k];
				t[i]=k;
			}
		}
		//cerr << dp[i] << ", " << t[i] << endl;
		if(r<dp[i]){
			r=dp[i];
			p=i;
		}
	}
	//cerr << p << endl;
	vector<int> ret;
	for(int i=0;i<p;i++){
		ret.push_back(1);
	}
	while(t[p]){
		for(int i=t[p]/2;i>=1;i--){
			ret.push_back(i+1);
		}
		p=p+t[p];
	}
	while(N-1-p){
		ret.push_back(N-p);
		N--;
	}
	cout << r << endl;
	cout << ret.size() << endl;
	for(auto v:ret){
		cout << v << endl;
	}
	return 0;
}

