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>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	
	int N;
	cin >> N;
	int A[1000];
	rep(i, N) cin >> A[i];

	ll dp[1001][4];
	rep(i, 1001) rep(j, 4) dp[i][j] = -1e18;
	dp[0][0] = 0;
	rep(i, N) {
		if (dp[i][0] != -1e18) {
			dp[i + 1][0] = max(dp[i + 1][0], dp[i][0]);
			dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + A[i]);
		}
		if (dp[i][1] != -1e18) {
			dp[i + 1][2] = max(dp[i + 1][2], dp[i][1]);
			dp[i + 1][3] = max(dp[i + 1][3], dp[i][1]);
		}
		if (dp[i][2] != -1e18) {
			dp[i + 1][1] = max(dp[i + 1][1], dp[i][2] + A[i]);
			dp[i + 1][1] = max(dp[i + 1][1], dp[i][2]);
		}
		if (dp[i][3] != -1e18) {
			dp[i + 1][3] = max(dp[i + 1][3], dp[i][3]);
		}
	}

	ll mae = *max_element(dp[N], dp[N] + 4);
	if (mae == 0) {
		int saidai = -2e9;
		int kazu = 0;
		rep(i, N) if (saidai < A[i]) {
			saidai = A[i];
			kazu = i;
		}
		co(saidai);
		co(N - 1);
		rep(i, N) if (N - 1 - i != kazu) co(N - i);
	}
	else {
		co(mae);
		int maeichi = N + 1;
		int flag = -1;
		vector<int> kotae, kotae3;
		vector<pair<int, int>> kotae2;
		int kotae2kazu = 0;
		for (int i = N - 1; i >= 0; i--) {
			if (flag == 1) kotae3.pb(0);
			else if (dp[i][2] + A[i] == mae && maeichi - 1 > i) {
				if (maeichi != N + 1) {
					int kari = (maeichi - i) / 2;
					kotae2.pb(mp(i + kari, kari));
					kotae2kazu += kari;
				}
				mae -= A[i];
				maeichi = i;
				flag = 0;
			}
			else if (dp[i][0] + A[i] == mae && maeichi - 1 > i) {
				if (maeichi != N + 1) {
					int kari = (maeichi - i) / 2;
					kotae2.pb(mp(i + kari, kari));
					kotae2kazu += kari;
				}
				mae -= A[i];
				maeichi = i;
				flag = 1;
			}
			else if (flag == -1) kotae.pb(i);
		}
		int size = kotae.size();
		size += kotae2kazu;
		size += kotae3.size();
		co(size);
		for (int i : kotae) co(i + 1);
		for (auto p : kotae2) {
			rep(i, p.second) co(p.first + 1 - i);
		}
		for (int i : kotae3) co(i + 1);
	}

	Would you please return 0;
}