import std.stdio, std.algorithm, std.range, std.conv, std.string;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

const int INF = 1_000_000_007;

void main() {
	int n;
	scanf("%d", &n);
	int[] a = new int[n];
	foreach (i; 0..n) scanf("%d", &a[i]);
	int p = 0, m = -INF; long val = -INF;
	foreach (parity; 0..2) {
		long sum = 0;
		int mx = -INF;
		foreach (i; 0..n) {
			if ((i&1) != parity) continue;
			if (a[i] > 0) sum += a[i];
			else mx = max(mx, a[i]);
		}
		if (sum == 0) sum = mx;
		if (val < sum) {
			p = parity;
			val = sum;
			if (sum == mx) m = mx;
			else m = -INF;
		}
	}
	writeln(val);
	int[] ans;
	int len = n;
	foreach_reverse (i; 0..n) {
		if ((i&1) != p) continue;
		if (a[i] <= 0) {
			if (a[i] == m) {
				m = -INF;
			} else {
				ans ~= i+1;
				if (i == n-1 || i == 0) len--;
				else len -= 2;
			}
		}
	}
	if (p) ans ~= 1, len--;
	foreach (i; 0..len/2) ans ~= 2;
	writeln(ans.length);
	foreach (i; ans) writeln(i);
}

