#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define cint(d) scanf("%d", &d)
#define cint2(a, b) scanf("%d %d", &a, &b)
#define cint3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define cint4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)

#define clong(d) scanf("%lld", &d)
#define clong2(a, b) scanf("%lld %lld", &a, &b)
#define clong3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define clong4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)

#define foreach(v, c) for(__typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define revforeach(v, c) for(__typeof( (c).rbegin()) v = (c).rbegin();  v != (c).rend(); ++v)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

typedef long long int slong;
typedef pair<int, int> pii;
typedef pair<slong, slong> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

#ifdef VSP4 
    #include "debug.h"    
#else
    #define debug(args...)                  // Just strip off all debug tokens
#endif

const int MOD = 1000000007;
#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define MODADDSET(d) if ((d) >= MOD) d -= MOD;
#define MODADDWHILESET(d) while ((d) >= MOD) d -= MOD;

const int MAXN = 1000;
const int SQRTN = 550;
const int LOGN = 18;

const int INT_INFINITY = 1001001001;
const long long int LONG_INFINITY = 1001001001001001001ll;
const long long int LARGEVALUE = 10010010010010ll;

const int LIMIT = 2e6;

int n;
slong arr[MAXN+5];

slong dp[MAXN+5];
int prevdp[MAXN+5];

int main()
{
	#ifdef VSP4
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	clock_t begin = clock();
	
	int t, i, j;

	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}

	slong ans = -LONG_INFINITY;

	for (int i = 1; i <= n; i++)
	{
		dp[i] = arr[i];
		for (int j = 2; i-j >= 1; j += 2)
		{
			slong curr = dp[i-j] + arr[i];
			if (curr > dp[i])
			{
				dp[i] = curr;
				prevdp[i] = i-j;
			}
		}

		ans = max(ans, dp[i]);
	}

	cout << ans << "\n";

	vector<int> ansarr;

	for (int i = 1; i <= n; i++)
	{
		if (dp[i] == ans)
		{
			for (int j = n; j >= i+1; j--)
			{
				ansarr.pb(j);
			}

			//ith element is last now
			vector<int> path;
			int curr = i;
			while (curr)
			{
				path.pb(curr);
				curr = prevdp[curr];
			}

			reverse(ALL(path));

			for (int i = 1; i < path[0]; i++)
			{
				ansarr.pb(1);
			}

			for (int i = 1; i < path.size(); i++)
			{
				//path[i-1] is first element
				//path[i] is path[i] - path[i-1] + 1 th element
				int diff = path[i] - path[i-1];

				for (int k = 1; k < diff/2; k++)
				{
					ansarr.pb(3);
				}

				ansarr.pb(2);
			}
			break;
		}
	}

	cout << ansarr.size() << "\n";
	for (auto s: ansarr)
	{
		cout << s << "\n";
	}

	clock_t end = clock();
	double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
	
	cerr << elapsed_secs << endl;
	
	return 0;
}


Measured memory_bytes: 256