#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

typedef long long ll;
ll n, x, a, s1, s2, mn = -2e9;
vector<ll> b, c[2];
int main()
{
	ll i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a);
		if (i % 2 == 0) s1 += max(a, 0LL);
		else s2 += max(a, 0LL);
		if (a > 0) {
			c[i % 2].push_back(i);
		}
		if (a > mn) {
			x = i;
			mn = a;
		}
	}
//	for (i =0; i < c[1].size(); i++) {
//		cout << c[1][i] << endl;
//	}
	if (s1 == 0 && s2 == 0) {
		for (i = 0; i < x; i++) {
			b.push_back(1);
		}
		for (i = n - x; i > 1; i--) {
			b.push_back(i);
		}
		cout << mn << endl;
		cout << b.size() << endl;
		for (i = 0; i < b.size(); i++) {
			printf("%lld\n", b[i]);
		}
	} else {
		if (s1 > s2) x = 0;
		else x = 1;
		for (i = n; i > c[x][c[x].size() - 1] + 1; i--) b.push_back(i);
		for (i = 0; i < c[x][0]; i++) b.push_back(1);
		for (i = 1; i < c[x].size(); i++) {
			for (j = (c[x][i] - c[x][i - 1]) / 2 + 1; j >= 2; j--) b.push_back(j);
		}
		cout << max(s1, s2) << endl;
		cout << b.size() << endl;
		for (i =0; i < b.size(); i++) {
			printf("%lld\n", b[i]);
		}
	}
    return 0;
}
