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)

//By Ralif Rakhmatullin
#include<iostream>
#include<fstream>
#include<string>
#include<cstring>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<ctime>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<bitset>
#include<valarray>
#include<iterator>
#include<list>
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define S second
#define ld long double
#define F first
#define y1 LOL
#define ld long double
#define pb push_back
#define len length
#define sz size
#define beg begin
const ll INF = (ll)1e18 + 123;
const int inf=(int)2e9 + 123; 
const int mod=1e9+7;
using namespace std;
int n, a[1011];
ll ev = 0, odd = 0;
bool is1 = 0, is2 = 0;
vector<int> v, ans;
int main(){
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  	srand(FOR);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin >> n;
	for(int i = 1; i <= n; i ++){
		cin >> a[i];
		if(a[i] >= 0){
			if(i % 2 == 1){
				odd += a[i];
				is1 = 1;
			}else{
				ev += a[i];
				is2 = 1;
			}
		}
	}
	if(!is1 && !is2){
		int mx = -inf, pos = 0;
		for(int i = 1; i <= n; i ++){
			if(a[i] > mx){
				mx = a[i];
				pos = i;
			}
		}
		cout << mx << "\n" << n - 1 << endl;
		while(n > pos){
			cout << n << endl;
			n --;
		}
		while(n > 1){
			cout << 1 << endl;
			n --;
		}
		return 0;
	}
	if(!is2 || odd > ev){
		cout << odd << endl;
		for(int i = 1; i <= n; i += 2){
			if(a[i] >= 0)
				v.pb(i);
		}
	}else{
		cout << ev << endl;
		for(int i = 2; i <= n; i += 2){
			if(a[i] >= 0)
				v.pb(i);
		}
	}
	int sz = (int)v.sz() - 1;
	while(n > v[sz]){	
		ans.pb(n);
		n --;
	}
	while(v[0] > 1){
		for(int j = 0; j <= sz; j ++){
			v[j] --;
		}
		ans.pb(1);
	}
	for(int i = 0; i < sz; i ++){
		while(v[i + 1] - v[i] > 2){
			ans.pb((v[i] + v[i + 1]) / 2);	
			for(int j = 1; j <= sz; j ++)
				v[j] -= 2;
		}	
		if(v[i] + 2 == v[i + 1]){
			ans.pb(v[i] + 1);
			v.erase(v.beg());
			sz --;
			for(int j = 0; j <= sz; j ++)
				v[j] -= 2;
			i --;
		}
	}
	cout << (int)ans.sz() << endl;
	for(auto x : ans)
		cout << x << endl;
	return 0;
}