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: Accepted)

#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	int n;
	cin >> n;
	vl a(n);
	bool sei = false;
	rep(i, n) {
		cin >> a[i];
		if (a[i] > 0) {
			sei = true;
		}
	}
	if (!sei) {
		ll ma = -INF;
		int idx = 0;
		rep(i, n) {
			if (ma < a[i]) {
				ma = a[i];
				idx = i;
			}
		}
		cout << ma << endl;
		cout << n - 1 << endl;
		while (a.size() > idx + 1) {
			cout << a.size() << endl;
			a.pop_back();
		}
		while (a.size() > 1) {
			cout << 1 << endl;
			a.erase(a.begin());
		}
		return 0;
	}
	ll ansgu = 0, anski = 0;
	rep(i, n) {
		if (a[i] > 0) {
			if (i % 2 == 0) {
				ansgu += a[i];
			}
			else {
				anski += a[i];
			}
		}
	}
	bool gu;
	ll ans;
	if (ansgu >= anski) {
		gu = true;
		ans = ansgu;
	}
	else {
		gu = false;
		ans = anski;
	}
	vi op;
	if (gu && a[0] <= 0) {
		op.push_back(0);
		a.erase(a.begin());
		gu = false;
	}
	if (!gu) {
		while (a.size() > 1) {
			bool done = false;
			rep(i, a.size()) {
				if (i % 2 == 1 && a[i] <= 0) {
					if (i == a.size() - 1) {
						op.push_back(i);
						a.pop_back();
					}
					else {
						op.push_back(i);
						a[i] = a[i - 1] + a[i + 1];
						a.erase(a.begin() + i + 1);
						a.erase(a.begin() + i - 1);
					}
					done = true;
					break;
				}
			}
			if (done) {
				continue;
			}
			for (int i = 1; i + 2 < a.size(); i += 2) {
				if (a[i] > 0 && a[i + 2] > 0) {
					op.push_back(i + 1);
					a[i + 1] = a[i] + a[i + 2];
					a.erase(a.begin() + i + 2);
					a.erase(a.begin() + i);
					done = true;
					break;
				}
			}
			if (done) {
				continue;
			}
			if (a.size() == 3) {
				op.push_back(2);
				a.pop_back();
				continue;
			}
			if (a.size() == 2) {
				op.push_back(0);
				a.erase(a.begin());
				continue;
			}
		}
	}
	else {
		while (a.size() > 1) {
			bool done = false;
			rep(i, a.size()) {
				if (i % 2 == 0 && a[i] <= 0) {
					if (i == a.size() - 1) {
						op.push_back(i);
						a.pop_back();
					}
					else {
						op.push_back(i);
						a[i] = a[i - 1] + a[i + 1];
						a.erase(a.begin() + i + 1);
						a.erase(a.begin() + i - 1);
					}
					done = true;
					break;
				}
			}
			if (done) {
				continue;
			}
			for (int i = 0; i + 2 < a.size(); i += 2) {
				if (a[i] > 0 && a[i + 2] > 0) {
					op.push_back(i + 1);
					a[i + 1] = a[i] + a[i + 2];
					a.erase(a.begin() + i + 2);
					a.erase(a.begin() + i);
					done = true;
					break;
				}
			}
			if (done) {
				continue;
			}
			if (a.size() == 2) {
				op.push_back(1);
				a.erase(a.begin() + 1);
				continue;
			}
		}
	}
	cout << ans << endl;
	cout << op.size() << endl;
	rep(i, op.size()) {
		cout << op[i] + 1 << endl;
	}

}