#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll HMOD = (ll)1e9 + 7;
const ll LMOD = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
const long double EPS = 1e-10;

void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

VPLL dec(VPLL v,int i){
	VPLL ret;
	if (i == 0) FOR(j, 1, v.size()) ret.push_back(v[j]);
	else if (i == v.size() - 1) REP(j, v.size() - 1) ret.push_back(v[j]);
	else {
		REP(j,v.size()){
			if (j < i - 1 || i + 1 < j) ret.push_back(v[j]);
			if (j == i) ret.push_back({ v[i - 1].fi + v[i + 1].fi, v[i].se });
		}
	}
	return ret;
}

int main() {
	int N; cin >> N;
	ll eve = 0, odd = 0;
	VL a(N),c; REP(i, N) cin >> a[i];
	bool neg = true;
	REP(i, N) if (a[i] >= 0) neg = false;
	
	if(neg){
		int idx = distance(a.begin(), max_element(ALL(a)));
		cout << a[idx] << endl;
		cout << N - 1 << endl;
		for (int i = N; i > idx+1; --i) cout << i << endl;
		for (int i = 1; i < idx+1; ++i) cout << 1 << endl;
		return 0;
	}

	VPLL arr;
	REP(i, N) if (a[i] >= 0) ((i % 2 == 0) ? eve : odd) += a[i];
	REP(i, N) arr.push_back({ a[i],i });

	bool prt = !(eve > odd);

	while(N >= 2){
		if (arr[0].se % 2 == prt && arr[0].fi >= 0) break;
		arr = dec(arr, 0);
		c.push_back(1);
		N = arr.size();
	}

	while (N >= 2) {
		if (arr[N-1].se % 2 == prt && arr[N-1].fi >= 0) break;
		arr = dec(arr, N-1);
		c.push_back(N);
		N = arr.size();
	}
		
	for (int i = 0; i < N && N >= 2;) {
		if (arr[i].fi >= 0) {
			i += 2;
			continue;
		}
		else {
			arr = dec(arr, i);
			c.push_back(i + 1);
			N = arr.size();
		}
	}
	
	while (N >= 2) {
		arr = dec(arr, 1);
		c.push_back(2);
		N = arr.size();
	}

	cout << arr[0].fi << endl;
	cout << c.size() << endl;
	REP(i, c.size()) cout << c[i] << endl;

	
	
	return 0;
}



Measured memory_bytes: 384