#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	int n;
	cin >> n;
	vl a(n);
	bool sei = false;
	rep(i, n) {
		cin >> a[i];
		if (a[i] > 0) {
			sei = true;
		}
	}
	if (!sei) {
		ll ma = -INF;
		int idx = 0;
		rep(i, n) {
			if (ma < a[i]) {
				ma = a[i];
				idx = i;
			}
		}
		cout << ma << endl;
		cout << n - 1 << endl;
		while (a.size() > idx + 1) {
			cout << a.size() << endl;
			a.pop_back();
		}
		while (a.size() > 1) {
			cout << 1 << endl;
			a.erase(a.begin());
		}
		return 0;
	}
	ll ansgu = 0, anski = 0;
	rep(i, n) {
		if (a[i] > 0) {
			if (i % 2 == 0) {
				ansgu += a[i];
			}
			else {
				anski += a[i];
			}
		}
	}
	bool gu;
	ll ans;
	if (ansgu >= anski) {
		gu = true;
		ans = ansgu;
	}
	else {
		gu = false;
		ans = anski;
	}
	vi op;
	if (gu && a[0] <= 0) {
		op.push_back(0);
		a.erase(a.begin());
		gu = false;
	}
	if (!gu) {
		while (a.size() > 1) {
			bool done = false;
			rep(i, a.size()) {
				if (i % 2 == 1 && a[i] <= 0) {
					if (i == a.size() - 1) {
						op.push_back(i);
						a.pop_back();
					}
					else {
						op.push_back(i);
						a[i] = a[i - 1] + a[i + 1];
						a.erase(a.begin() + i + 1);
						a.erase(a.begin() + i - 1);
					}
					done = true;
					break;
				}
			}
			if (done) {
				continue;
			}
			for (int i = 1; i + 2 < a.size(); i += 2) {
				if (a[i] > 0 && a[i + 2] > 0) {
					op.push_back(i + 1);
					a[i + 1] = a[i] + a[i + 2];
					a.erase(a.begin() + i + 2);
					a.erase(a.begin() + i);
					done = true;
					break;
				}
			}
			if (done) {
				continue;
			}
			if (a.size() == 3) {
				op.push_back(2);
				a.pop_back();
				continue;
			}
			if (a.size() == 2) {
				op.push_back(0);
				a.erase(a.begin());
				continue;
			}
		}
	}
	else {
		while (a.size() > 1) {
			bool done = false;
			rep(i, a.size()) {
				if (i % 2 == 0 && a[i] <= 0) {
					if (i == a.size() - 1) {
						op.push_back(i);
						a.pop_back();
					}
					else {
						op.push_back(i);
						a[i] = a[i - 1] + a[i + 1];
						a.erase(a.begin() + i + 1);
						a.erase(a.begin() + i - 1);
					}
					done = true;
					break;
				}
			}
			if (done) {
				continue;
			}
			for (int i = 0; i + 2 < a.size(); i += 2) {
				if (a[i] > 0 && a[i + 2] > 0) {
					op.push_back(i + 1);
					a[i + 1] = a[i] + a[i + 2];
					a.erase(a.begin() + i + 2);
					a.erase(a.begin() + i);
					done = true;
					break;
				}
			}
			if (done) {
				continue;
			}
			if (a.size() == 2) {
				op.push_back(1);
				a.erase(a.begin() + 1);
				continue;
			}
		}
	}
	cout << ans << endl;
	cout << op.size() << endl;
	rep(i, op.size()) {
		cout << op[i] + 1 << endl;
	}

}

Measured memory_bytes: 256