#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

const int MAXN = 1e3 + 5;

int ar[MAXN];
ll pref[MAXN][2];
ll dp[MAXN][2];
int best[MAXN][2];

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &ar[i]);
    for (int i = 1; i <= n; i++) {
        for (int f = 0; f <= 1; f++) {
            if ((i & 1) == f) {
                pref[i][f] = pref[i - 1][f] + ar[i];
            } else {
                pref[i][f] = pref[i - 1][f];
            }
        }
    }
    int max_pos = max_element(ar + 1, ar + n + 1) - ar;
    if (ar[max_pos] <= 0) {
        printf("%d\n", ar[max_pos]);
        printf("%d\n", n - 1);
        for (int i = n; i > max_pos; i--)
            printf("%d\n", i);
        for (int i = 1; i < max_pos; i++)
            printf("1\n");
        return 0;
    }
    ll ans = 0;
    for (int st = 1; st <= 2; st++) {
        for (int en = n - 1; en <= n; en++) {
            memset(best, -1, sizeof best);
            memset(dp, 0, sizeof dp);
            for (int i = st; i <= en; i++) {
                for (int f = 0; f <= 1; f++) {
                    dp[i][f] = -( ll )1e14;
                    int par = i & 1;
                    for (int j = st - 1; j < i; j++) {
                        if (((i - j) & 1) == 0)
                            continue;
                        ll cur = dp[j][f ^ 1] + (pref[i][par] - pref[j][par]) * f;
                        if (cur > dp[i][f]) {
                            dp[i][f] = cur;
                            best[i][f] = j;
                        }
                    }
                }
            }
            ans = max(ans, max(dp[en][0], dp[en][1]));
        }
    }
    printf("%lld\n", ans);
    for (int st = 1; st <= 2; st++) {
        for (int en = n - 1; en <= n; en++) {
            memset(best, -1, sizeof best);
            memset(dp, 0, sizeof dp);
            for (int i = st; i <= en; i++) {
                for (int f = 0; f <= 1; f++) {
                    dp[i][f] = -( ll )1e14;
                    int par = i & 1;
                    for (int j = st - 1; j < i; j++) {
                        if (((i - j) & 1) == 0)
                            continue;
                        ll cur = dp[j][f ^ 1] + (pref[i][par] - pref[j][par]) * f;
                        if (cur > dp[i][f]) {
                            dp[i][f] = cur;
                            best[i][f] = j;
                        }
                    }
                }
            }
            bool found = false;
            int i, f;
            if (ans == dp[en][0]) {
                found = true;
                i = en, f = 0;
            } else if (ans == dp[en][1]) {
                found = true;
                i = en, f = 1;
            }
            if (!found) continue;
            vi ops;
            if (en == n - 1) ops.pb(n);
            int cnt = 0, last = f;
            while (i >= st) {
                int j = best[i][f];
                for (int k = j + 2; k < i; k += 2)
                    ops.pb(j + 2);
                if (f == 0) cnt++;
                last = f;
                i = j;
                f ^= 1;
            }
            if (st == 2) ops.pb(1);
            //printf("last = %d and cnt = %d\n", last, cnt);
            if (last == 0) {
                ops.pb(1);
                cnt--;
            }
            while (cnt--) {
                ops.pb(2);
            }
            printf("%d\n", (int)ops.size());
            for (auto it : ops) printf("%d\n", it);
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 256