#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<tuple<long long, long long, long long, long long>> inputs;
long long required_costs[300000] = {};
long long winning_value[300000] = {};
long long n, x;
long long solve(long long now, long long border) {
	long long cost = winning_value[now] - required_costs[now];
	if (border < now) {
		cost -= x * get<3>(inputs[border]);
		cost += get<1>(inputs[border]) * get<3>(inputs[border]);
		cost -= get<1>(inputs[border]) * get<2>(inputs[border]);
	}
	return cost;
}
int main(){
#define int long long	
	int n;
	cin >> n;
	vector<pair<int,int>> inputs;
	long long geko = -1;
	REP(i, n) {
		long long a;
		cin >> a;
		geko = max(geko, a);
		inputs.push_back(make_pair(a, 0));
	}
	vector<long long> ans_swapping;
	if (geko == -1) {
		//よしコーナー
		long long now_minnest = -LONG_INF;
		long long now_itr = 0;
		for (int q = 0; q < inputs.size(); ++q) {
			if (now_minnest < inputs[q].first) {
				now_minnest = inputs[q].first;
				now_itr = q;
			}
		}
		for (int j = 0; j < now_itr; ++j) {
			ans_swapping.push_back(1);
			vector<pair<int,int>> nekoi;
			REP(t, inputs.size()-1) {
				nekoi.push_back(inputs[t + 1]);
			}
			inputs = nekoi;
		}
		while (inputs.size() != 1) {
			ans_swapping.push_back(inputs.size());
			inputs.pop_back();
		}
	}
	else {
		long long ans[2] = {};
		REP(i, inputs.size()) {
			ans[i % 2] += max(0LL, inputs[i].first);
		}
		if (ans[0] < ans[1]) {
			REP(i, inputs.size()) {
				if (i % 2 == 1&&inputs[i].first >= 0) {
					inputs[i].second = 1;
				}
			}
		}
		else {
			REP(i, inputs.size()) {
				if (i % 2 == 0&&inputs[i].first >= 0) {
					inputs[i].second = 1;
				}
			}
		}
		while(inputs[0].second == 0){
			ans_swapping.push_back(1);
			vector<pair<int, int>> nekoi;
			REP(t, inputs.size() - 1) {
				nekoi.push_back(inputs[t + 1]);
			}
			inputs = nekoi;
		}
		while (inputs[inputs.size() - 1].second == 0) {
			ans_swapping.push_back(inputs.size());
			inputs.pop_back();
		}
		while (inputs.size() != 1) {
			for (int q = 1; q < inputs.size()-1; ++q) {
				if (inputs[q - 1].second == inputs[q + 1].second && inputs[q].second == 0) {
					ans_swapping.push_back(q + 1);
					inputs[q] = make_pair(inputs[q - 1].first + inputs[q + 1].first, inputs[q + 1].second);
					inputs.erase(inputs.begin() + q - 1);
					inputs.erase(inputs.begin() + q);
				}
			}
		}
	}
	cout << inputs[0].first << endl;
	cout << ans_swapping.size() << endl;
	REP(i, ans_swapping.size()) {
		cout << ans_swapping[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 888