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;

    if (A.map!(a => a <= 0).all) {
        long maxv = -INF;
        long maxi = -1;
        foreach (i; 0..N) if (A[i] > maxv) maxv = A[i], maxi = i;
        maxv.writeln;
        (N-1).writeln;
        foreach_reverse (i; maxi+1..N) (i+1).writeln;
        foreach (i; 0..maxi) 1.writeln;
        return;
    }
    
    auto B = iota(0, N, 2).array;
    auto C = iota(1, N, 2).array;
    auto ansB = B.map!(i => A[i] <= 0).all ? -INF : B.map!(i => max(0, A[i])).sum;
    auto ansC = C.map!(i => A[i] <= 0).all ? -INF : C.map!(i => max(0, A[i])).sum;
    int[] ans, to_remove;
    
    if (ansB >= ansC) {
        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 (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;
}
