#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 2e5 + 10;
long long su[1005];
vector<int> seq;
 
int main(){
    int n;
    bool non_pos = true;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&su[i]);
        if(su[i]>0) non_pos = false;
    }
    if(non_pos){
        int ans = 1;
        for(int i=2;i<=n;i++){
            if(su[ans] < su[i]) ans = i;
        }
        printf("%lld\n%d\n", su[ans], n-1);
        for(int i=n;i>ans;i--){
            printf("%d\n", i);
        }
        for(int i=1;i<ans;i++){
            printf("%d\n", 1);
        }
    }else{
        long long odd = 0, even = 0;
        for(int i=1;i<=n;i++){
            if(su[i] > 0){
                if(i%2){
                    odd += su[i];
                }else{
                    even += su[i];
                }
            }
        }
        if(odd > even)
        {
            int ss = -1, ee = -1;
            printf("%lld\n", odd);
            rrep(i, n, 1)
            {
                if(su[i] <= 0 || (i % 2) == 0) seq.pb(i);
                else 
                {
                    ee = i;
                    break;
                }
            }
            for(int i = 1; i <= n; i += 2)
            {
                if(su[i] <= 0)
                {
                    seq.push_back(1);
                    seq.push_back(1);
                }
                else
                {
                    ss = i;
                    break;
                }
            }
            for(int i=ss+2;i<=ee;i+=2){
                if(su[i] <= 0){
                    seq.push_back(3);
                }else{
                    seq.push_back(2);
                }
            }
        }else{
            int ss = -1, ee = -1;
            printf("%lld\n", even);
            for(int i=n;i>=1;i--){
                if(su[i] <= 0 || (i%2) == 1){
                    seq.push_back(i);
                }else{
                    ee = i;
                    break;
                }
            }
            seq.push_back(1);
            for(int i=2;i<=n;i+=2){
                if(su[i] <= 0){
                    seq.push_back(1);
                    seq.push_back(1);
                }else{
                    ss = i;
                    break;
                }
            }
            for(int i=ss+2;i<=ee;i+=2){
                if(su[i] <= 0){
                    seq.push_back(3);
                }else{
                    seq.push_back(2);
                }
            }
        }
        printf("%d\n", seq.size());
        for(auto &elem: seq) printf("%d\n", elem);
    }
}

Measured memory_bytes: 256