//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

void nonnegative_root(const vector<ll>& as) {
	ll idx = 0, val = -(1LL << 60LL);
	for (ll i = 0; i < as.size(); ++i) {
		if (as[i] > val) {
			idx = i;
			val = as[i];
		}
	}
	++idx;
	
	vector<ll> res;
	ll count = as.size();
	while (count > idx) {
		res.push_back(count);
		--count;
	}
	count = 1;
	while (count < idx) {
		res.push_back(1);
		++count;
	}

	cout << val << endl;
	cout << res.size() << endl;
	for (ll i = 0; i < res.size(); ++i) {
		cout << res[i] << endl;
	}

	return;
}

void even_root(const vector<ll>& as) {
	ll left = -1, right = 0, val = 0;
	for (ll i = 0; i < as.size(); i += 2) {
		if (as[i] >= 0) {
			if (left == -1) left = i;
			right = i;
			val += as[i];
		}
	}
	++left, ++right;

	vector<ll> res;
	ll count = as.size();
	while (count > right) {
		res.push_back(count);
		--count;
	}
	count = 1;
	while (count < left) {
		res.push_back(1);
		++count;
	}

	for (ll i = (left - 1) + 2; i < right; i += 2) {
		if (as[i] >= 0) {
			res.push_back(2);
		}
		else {
			res.push_back(3);
		}
	}

	cout << val << endl;
	cout << res.size() << endl;
	for (ll i = 0; i < res.size(); ++i) {
		cout << res[i] << endl;
	}

	return;
}

void odd_root(const vector<ll>& as) {
	ll left = -1, right = 0, val = 0;
	for (ll i = 1; i < as.size(); i += 2) {
		if (as[i] >= 0) {
			if (left == -1) left = i;
			right = i;
			val += as[i];
		}
	}
	++left, ++right;

	vector<ll> res;
	ll count = as.size();
	while (count > right) {
		res.push_back(count);
		--count;
	}
	count = 1;
	while (count < left) {
		res.push_back(1);
		++count;
	}

	for (ll i = (left - 1) + 2; i < right; i += 2) {
		if (as[i] >= 0) {
			res.push_back(2);
		}
		else {
			res.push_back(3);
		}
	}

	cout << val << endl;
	cout << res.size() << endl;
	for (ll i = 0; i < res.size(); ++i) {
		cout << res[i] << endl;
	}

	return;
}

int solve() {
	ll n;
	cin >> n;

	vector<ll> as(n);
	for (ll i = 0; i < n; ++i) cin >> as[i];

	bool exist_nonnegative = false;
	ll even_accum = 0, odd_accum = 0;
	for (ll i = 0; i < n; ++i) {
		if (as[i] >= 0) exist_nonnegative = true;
		if (i % 2 == 0 && as[i] >= 0) even_accum += as[i];
		if (i % 2 == 1 && as[i] >= 0) odd_accum += as[i];
	}
	if (!exist_nonnegative) nonnegative_root(as);
	else if (even_accum > odd_accum) even_root(as);
	else odd_root(as);

	return 0;
}

//main function
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;
}


Measured memory_bytes: 384