import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    immutable long INF = 1L << 59;
    
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    auto B = iota(0, N, 2).array;
    auto C = iota(1, N, 2).array;
    
    auto maxB = B.map!(i => tuple(A[i], i)).reduce!max;
    auto maxC = C.map!(i => tuple(A[i], i)).reduce!max;
    auto ansB = B.map!(i => max(0, A[i])).sum;
    auto ansC = C.map!(i => max(0, A[i])).sum;
    if (B.map!(i => A[i] > 0).sum <= 1) ansB = maxB[0];
    if (C.map!(i => A[i] > 0).sum <= 1) ansC = maxC[0];
    int[] ans, to_remove;

    if (ansB >= ansC) {
        if (B.map!(i => A[i] > 0).sum <= 1) {
            ansB = maxB[0];
            foreach_reverse (i; maxB[1]+1..N) ans ~= i+1;
            foreach (i; 0..maxB[1]) ans ~= 1;
        } else {
            if (N % 2 == 0) ans ~= N;
            foreach_reverse (i; B) if (A[i] <= 0) to_remove ~= i+1;
            ans ~= to_remove;
            foreach (i; 0..(B.length.to!int - to_remove.length.to!int - 1)) ans ~= 2;
        }
    } else {
        if (C.map!(i => A[i] > 0).sum <= 1) {
            ansC = maxC[0];
            foreach_reverse (i; maxC[1]+1..N) ans ~= i+1;
            foreach (i; 0..maxC[1]) ans ~= 1;
        } else {
            if (N % 2 == 1) ans ~= N;
            foreach_reverse (i; C) if (A[i] <= 0) to_remove ~= i+1;
            ans ~= to_remove;
            foreach (i; 0..(C.length.to!int - to_remove.length.to!int - 1)) ans ~= 3;
            ans ~= 1;
        }
    }

    max(ansB, ansC).writeln;
    ans.length.writeln;
    ans.each!writeln;
}
