Problem:
Score : 700 points

Problem Statement

You have an integer sequence of length N: a_1, a_2, ..., a_N.

You repeatedly perform the following operation until the length of the sequence becomes 1:

First, choose an element of the sequence.

If that element is at either end of the sequence, delete the element.

If that element is not at either end of the sequence, replace the element with the sum of the two elements that are adjacent to it. Then, delete those two elements.

You would like to maximize the final element that remains in the sequence.

Find the maximum possible value of the final element, and the way to achieve it.

Constraints

All input values are integers.

2 \leq N \leq 1000

|a_i| \leq 10^9

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

In the first line, print the maximum possible value of the final element in the sequence.

In the second line, print the number of operations that you perform.

In the (2+i)-th line, if the element chosen in the i-th operation is the x-th element from the left in the sequence at that moment, print x.

If there are multiple ways to achieve the maximum value of the final element, any of them may be printed.

Sample Input 1

5
1 4 3 7 5

Sample Output 1

11
3
1
4
2

The sequence would change as follows:

After the first operation: 4, 3, 7, 5

After the second operation: 4, 3, 7

After the third operation: 11(4+7)

Sample Input 2

4
100 100 -1 100

Sample Output 2

200
2
3
1

After the first operation: 100, 200(100+100)

After the second operation: 200

Sample Input 3

6
-1 -2 -3 1 2 3

Sample Output 3

4
3
2
1
2

After the first operation: -4, 1, 2, 3

After the second operation: 1, 2, 3

After the third operation: 4

Sample Input 4

9
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

Sample Output 4

5000000000
4
2
2
2
2

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/









int N; ll A[1010];
ll B[2][1010];
//---------------------------------------------------------------------------------------------------
pair<ll,int> memoLF[1010][1010], memoRF[1010][1010], memoF[1010][1010];
pair<ll, int> LF(int l, int r) {
    if (memoLF[l][r].first != -infl) return memoLF[l][r];
    if (l % 2 != r % 2) return LF(l + 1, r);

    ll sm = B[r % 2][r];
    if (l) sm -= B[l % 2][l - 1];
    pair<ll, int> res = { sm, l * 1010 + r };

    if(l < r) res = max(res, LF(l + 2, r));
    return memoLF[l][r] = res;
}
pair<ll, int> RF(int l, int r) {
    if (memoRF[l][r].first != -infl) return memoRF[l][r];
    if (l % 2 != r % 2) return RF(l, r - 1);

    ll sm = B[r % 2][r];
    if (l) sm -= B[l % 2][l - 1];
    pair<ll, int> res = { sm, l * 1010 + r };

    if (l < r) res = max(res, RF(l, r - 2));
    return memoRF[l][r] = res;
}
pair<ll, int> F(int l, int r) {
    if (memoF[l][r].first != -infl) return memoF[l][r];
    if (l % 2 != r % 2) {
        return memoF[l][r] = max(F(l + 1, r), F(l, r - 1));
    }

    ll sm = B[r % 2][r];
    if (l) sm -= B[l % 2][l - 1];
    pair<ll, int> res = { sm, l * 1010 + r };

    if (l < r) {
        chmax(res, F(l + 2, r));
        chmax(res, F(l, r - 2));
    }
    return memoF[l][r] = res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) B[i % 2][i] = A[i];
    rep(d, 0, 2) rep(i, 1, N) B[d][i] += B[d][i - 1];
    rep(l, 0, N) rep(r, 0, N) memoF[l][r] = memoLF[l][r] = memoRF[l][r] = { -infl, 0 };

    ll ans = -infl; int opt_cent = -1;
    pair<ll, int> lft, rht;
    rep(cent, 1, N - 1) {
        pair<ll, int> al = LF(0, cent - 1);
        pair<ll, int> ar = RF(cent + 1, N - 1);

        pair<ll, int> bl, br;

        ll a = al.first + ar.first;

        ll b = -infl;
        if (0 <= cent - 2 and cent + 2 <= N - 1) {
            bl = F(0, cent - 2);
            br = F(cent + 2, N - 1);
            b = bl.first + br.first;
        }

        ll c = max(a, b);
        if (ans < c) {
            ans = c;
            opt_cent = cent;

            if (a < b) lft = bl, rht = br;
            else lft = al, rht = ar;
        }
    }

    cout << ans << endl;

    vector<int> buf;
    
    int a = lft.second / 1010;
    int b = lft.second % 1010;

    int c = rht.second / 1010;
    int d = rht.second % 1010;

    rep(i, 0, a) {
        buf.push_back(0);
        a--; b--; c--; d--; N--; opt_cent--;
    }
    rep(i, 0, N - d - 1) buf.push_back(N - 1 - i);
    N = d;

    rep(i, 0, (b - a) / 2) buf.push_back(1);
    c -= b - a;
    d -= b - a;
    b = a;

    rep(i, 0, (d - c) / 2) buf.push_back(c + 1);
    c = d;

    int dlt = opt_cent - b;
    if (dlt == 1) {
        buf.push_back(1);
    } else {
        if (dlt % 2 == 0) {
            buf.push_back(opt_cent);
            opt_cent--;
            c -= 2; d -= 2; N -= 2;
        }

        int fr = (opt_cent - b) / 2;
        rep(i, 0, fr) {
            buf.push_back(2);
            opt_cent -= 2;
            c -= 2; d -= 2; N -= 2;
        }

        fr = (c - opt_cent) / 2;
        rep(i, 0, fr) {
            buf.push_back(4);
            opt_cent -= 2;
            c -= 2; d -= 2; N -= 2;
        }

        buf.push_back(2);
        buf.push_back(1);
    }

    int n = buf.size();
    printf("%d\n", n);
    rep(i, 0, n) printf("%d\n", buf[i] + 1);
}