/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e3 + 10;
const ll inf = 1e15;

ll a[N];
vector<int> ops;

ll solve(int l, int r);

int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	ll best = -inf, best_p = -1;
	for (int i = 1; i <= n; ++i) {
		ll temp = solve(i, n);
		if (temp > best) {
			best = temp;
			best_p = i;
		}
	}
	solve(best_p, n);
	cout << best << endl;
	cout << ops.size() << endl;
	for (auto &i : ops) {
		cout << i << '\n';
	}
}

ll solve(int l, int r) {
	ops.clear();
	int offset = -(l - 1);
	ll ans = a[l];
	for (int j = 1; j < l; ++j) {
		ops.pb(1);
	}
	for (int i = l + 1; i <= r; ++i) {
		if (i == r) {
			ops.pb(i + offset);
		} else if (a[i + 1] >= 0) {
			ans += a[i + 1];
			ops.pb(i + offset);
			offset -= 2;
			++i;
		} else if (i + 2 <= r) {
			ops.pb(i + 1 + offset);
			offset -= 2;
			++i;
		} else {
			ops.pb(i + 1 + offset);
			ops.pb(i + offset);
			break;
		}
	}
	return ans;
}