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

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

