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 = new long[][](2, N+1);
    foreach (i; 0..N) B[i%2][i+1] = A[i];
    foreach (i; 0..2) foreach (j; 0..N) B[i][j+1] += B[i][j];

    long maxv = -INF;
    int maxl = -1;
    int maxr = -1;

    foreach (i; 0..N) {
        foreach (j; i..N) {
            if ((j - i + 1) % 2 != 1) continue;
            long v = B[i%2][j+1] - B[i%2][i];
            if (v > maxv) {
                maxv = v;
                maxl = i;
                maxr = j;
            }
        }
    }

    int step = maxl + (N - maxr - 1) + (maxr - maxl) / 2;
    maxv.writeln;
    step.writeln;
    foreach_reverse (i; maxr+1..N) writeln(i+1);
    foreach_reverse (i; iota(maxl+1, maxr, 2)) writeln(i+1);
    foreach (i; 0..maxl) writeln(1);
}
