#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int n;
long long mx = -2e9;
long long temp[2];
vector<long long>v,ans;
int main(){
	//freopen("input.txt","r",stdin);
	scanf("%d",&n);
	v.resize(n);
	for(int i = 0;i < n;i++)scanf("%lld",&v[i]),temp[i&1]+=max(v[i],0LL),mx = max(mx,v[i]);
	if(mx <= 0 && mx > -2e9){	
		cout << mx << endl << n - 1 << endl;
		int id = -1;
		for(int i = 0;i < n;i++)if(v[i] == mx)id = i;
		for(int i = n - 1;i > id;i--)cout << i + 1 << endl;
		for(int i = 0;i < id;i++)cout << 1 << endl;
		return 0;
	}
	cout << max(temp[0],temp[1]) << endl;
	bool lol = temp[0] < temp[1];
	while(v.size() >= 3){
		if((lol&1) == (v.size()&1))v.pop_back(),ans.push_back(v.size() + 1);
		else if(v.back() <= 0)v.pop_back(),ans.push_back(v.size() + 1);
		else{
			if(v[v.size() - 3] < 0){
				ans.push_back(v.size() - 2);
				if(v.size() - 3 == 0)v.erase(v.begin());
				else{
					v[v.size() - 3] = v[v.size() - 4] + v[v.size() - 2];
					v.erase(v.begin() + v.size() - 2);
					v.erase(v.begin() + v.size() - 3);
				}
			}
			else{
				ans.push_back(v.size() - 1);
				long long sum = v.back() + v[v.size() - 3];
				for(int i = 0;i < 3;i++)v.pop_back();
				v.push_back(sum);
			}
		}
	}
	if(v.size() > 1)
		if(v.front() < v.back())ans.push_back(1);
		else ans.push_back(2);
	printf("%d\n",ans.size());
	for(auto i : ans)printf("%lld\n",i);
}