#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int a[1005];
stack<int>alive;
vector<int>ans;
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	int mx = -inf, id = -1;
	rep(i, n) {
		mx = max(mx, a[i]);
		if (mx == a[i])id = i;
	}
	if (mx <= 0) {
		cout << mx << endl << n - 1 << endl;
		rep(i, id)cout << 1 << endl;
		n -= id;
		while (n != 1) {
			cout << n << endl; n--;
		}
		return 0;
	}
	int es = 0, os = 0;
	rep(i, n) {
		if (i & 1) {
			if (a[i] > 0)es += a[i];
		}
		else {
			if (a[i] > 0)os += a[i];
		}
	}
	if (es > os) {
		cout << es << endl;
		rep(i, n) {
			if ((i & 1) && a[i] > 0)alive.push(i);
		}
	}
	else {
		cout << os << endl;
		rep(i, n) {
			if (!(i & 1) && a[i] > 0)alive.push(i);
		}
	}
	int ntop = alive.top();
	while (n != ntop + 1) {
		ans.push_back(n);
		n--;
	}

	while (alive.size() != 1) {
		int x = alive.top();
		alive.pop();
		int s = alive.top();
		while (x - s != 2) {
			ans.push_back(x-1);
			x -= 2;
			n -= 2;
		}
		ans.push_back(x);
	}
	ntop = alive.top();
	rep(i, ntop)ans.push_back(1);
	cout << ans.size() << endl;
	rep(i, ans.size())cout << ans[i] << endl;
}
