#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<class Val>
struct BinaryIndexedTree {
    int n;
    vector<Val> t;
    BinaryIndexedTree() {}
    BinaryIndexedTree(int _n) :n(_n + 1), t(_n + 1) {}
    void add(int k, Val val) {
        k++;
        while (k < n) {
            t[k] += val;
            k += (k&-k);
        }
    }
    void set(int k, Val val) {
        add(k, -sum(k, k + 1));
        add(k, val);
    }
    Val sum(int k) {
        Val r = 0;
        while (k > 0) {
            r += t[k];
            k -= (k&-k);
        }
        return r;
    }
    Val sum(int l, int r) {
        return sum(r) - sum(l);
    }
};
typedef BinaryIndexedTree<int> BIT;

int N, A[1001];
BIT bit;
set<int> S;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    cin >> N;
    int ma = INT_MIN;
    ll odd = 0, even = 0;
    rep(i, N) {
        cin >> A[i];
        smax(ma, A[i]);
        if (A[i] > 0)(i % 2 ? odd : even) += A[i];
    }

    if (ma <= 0) {
        rep(i, N)if (A[i] == ma) {
            cout << ma << endl;
            cout << N - 1 << endl;
            // [i+1, N)を削除
            for (int j = N; j > i + 1; --j) {
                cout << j << endl;
            }
            // [0, i)を削除
            rep(j, i)cout << 1 << endl;
        }
        return 0;
    }

    bit = BIT(N);
    ll ans = max(odd, even);
    cout << ans << endl;
    vi sousa;
    int parity = odd >= even ? 1 : 0, L = -1, R = -1;
    for (int i = N - 1; i >= 0; i -= 2) {
        if (i % 2 != parity)i++;
        if (A[i] > 0) {
            for (int j = N; j > i + 1; --j)sousa.push_back(j);
            R = i + 1;
            break;
        }
    }
    for (int i = parity; i < N; i += 2)if (A[i] > 0) {
        rep(j, i)sousa.push_back(1);
        L = i;
        break;
    }

    FOR(i, L, R) {
        S.insert(i);
        bit.add(i, 1);
    }

    int lb = -1, ub = -1;
    for (int i = L; i < R; i += 2) if (A[i] > 0) {
        ub = i;
        if (lb != -1) {
            int mid = (lb + ub) / 2;
            while (1) {
                auto a = S.lower_bound(mid);
                auto b = S.lower_bound(mid);
                if (a == S.begin())break;
                sousa.push_back(bit.sum(mid + 1));
                --a; ++b;
                bit.add(*a, -1);
                bit.add(*b, -1);
                S.erase(a);
                S.erase(b);
            }
        }
        lb = ub;
    }
    cout << sz(sousa) << endl;
    each(x, sousa)cout << x << endl;
}

Measured memory_bytes: 384