#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    int mxi = max_element(A.begin(), A.end()) - A.begin();
    int64_t ans = A[mxi];
    vector<int> ansv = {mxi};
    for(int k=0; k<2; k++){
        int64_t res = 0;
        vector<int> resv;
        for(int i=k; i<N; i+=2) if(A[i] > 0){
            res += A[i];
            resv.push_back(i);
        }
        if(res > 0 && res > ans){
            ans = res;
            ansv = resv;
        }
    }
    vector<int> op;
    int tail = N-1;
    while(tail > ansv.back()) op.push_back(tail--);
    int sz = ansv.size();
    while(sz >= 2){
        int s = ansv[sz-2], t = ansv[sz-1];
        while(t-s > 2){
            op.push_back(s+2);
            t -= 2;
        }
        op.push_back(s+1);
        ansv.pop_back();
        sz--;
    }
    while(ansv[0]--) op.push_back(0);
    
    cout << ans << endl;
    cout << op.size() << endl;
    for(int a : op) cout << a+1 << endl;
}