#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

ll sum[1010][1010];

int main(){
	int n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	bool f = true;
	rep(i,n) if(a[i] > 0) f = false;
	vl ans;
	if(f){
		cout << *max_element(all(a)) << "\n";
		int id = max_element(all(a)) - a.begin();
		for(int i=n-1; i>=id+1; i--) ans.push_back(i+1);
		rep(i,id) ans.push_back(1);
	}else{
		vl sum(2,0);
		rep(i,n){
			sum[i&1] += max(0LL,a[i]);
		}
		if(sum[0] > sum[1]){
			if(n & 1){
				if(a.back() < 0) ans.push_back(n), a.pop_back();
				for(int i=n-3; i>=2; i-=2){
					if(a[i] < 0){
						a.erase(a.begin()+i+1);
						a.erase(a.begin()+i-1);
						ans.push_back(i+1);
					}
				}
			}else{
				for(int i=n-2; i>=2; i-=2){
					if(a[i] < 0){
						a.erase(a.begin()+i+1);
						a.erase(a.begin()+i-1);
						ans.push_back(i+1);
					}
				}
			}
			if(a[0] < 0){
				rep(i,2){
					a.erase(a.begin());
					ans.push_back(1);
				}
			}
			if((int)a.size() % 2 == 0){
				ans.push_back(a.size());
				a.pop_back();
			}
		}else{
			if(n & 1){
				for(int i=n-2; i>=1; i-=2){
					if(a[i] < 0){
						a.erase(a.begin()+i+1);
						a.erase(a.begin()+i-1);
						ans.push_back(i+1);
					}
				}
			}else{
				if(a.back() < 0) ans.push_back(n), a.pop_back();
				for(int i=n-3; i>=1; i-=2){
					if(a[i] < 0){
						a.erase(a.begin()+i+1);
						a.erase(a.begin()+i-1);
						ans.push_back(i+1);
					}
				}
			}
			a.erase(a.begin());
			ans.push_back(1);
		}
		cout << max(sum[0], sum[1]) << "\n";
		rep(i,a.size()/2) ans.push_back(2);
	}
	cout << ans.size() << "\n";
	rep(i,ans.size()) cout << ans[i] << "\n";
}

Measured memory_bytes: 3588