//#define NDEBUG
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
constexpr double PI = 3.1415926535897932;

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;

void yes(bool c) { puts(c ? "yes" : "no"); }
void Yes(bool c) { puts(c ? "Yes" : "No"); }
void YES(bool c) { puts(c ? "YES" : "NO"); }
void pos(bool c) { puts(c ? "possible" : "impossible"); }
void Pos(bool c) { puts(c ? "Possible" : "Impossible"); }
void POS(bool c) { puts(c ? "POSSIBLE" : "IMPOSSIBLE"); }
template<class T>bool bmaxi(T&a, const T&b) { if (b<a)return 0;a = b;return 1; }
template<class T>bool bmini(T&a, const T&b) { if (a<b)return 0;a = b;return 1; }
template<class T>bool nmaxi(T&a, const T&b) { if (a<b) { a = b;return 1; }return 0; }
template<class T>bool nmini(T&a, const T&b) { if (b<a) { a = b;return 1; }return 0; }
template<typename T>auto scan(T&d)->typename std::enable_if<std::is_signed<T>::value>::type {
	d = 0;int c = fgetc(stdin);bool f = 0;while (c<'0' || '9'<c) { if (c == '-')f = 1;c = fgetc(stdin); }
	while ('0' <= c&&c <= '9') { d = d * 10 + c - '0';c = fgetc(stdin); }if (f)d = -d;
}
template<typename T>auto scan(T&d)->typename std::enable_if<!std::is_signed<T>::value>::type {
	d = 0;int c = fgetc(stdin);while (c<'0' || '9'<c)c = fgetc(stdin);
	while ('0' <= c&&c <= '9') { d = d * 10 + c - '0';c = fgetc(stdin); }
}
template<>void scan(char&d) { d = fgetc(stdin);while (d<'a' || 'z'<d)d = fgetc(stdin); }
template<>void scan(double&d) { scanf("%lf", &d); }
template<>void scan(std::string&d) {
	d.clear();int c = fgetc(stdin);
	while (c<'a' || 'z'<c)c = fgetc(stdin);while ('a' <= c&&c <= 'z') { d.push_back(c);c = fgetc(stdin); }
}
template<typename F, typename...R>void scan(F&f, R&...r) { scan(f);scan(r...); }
template<typename T>T input() { T d;scan(d);return d; }
#include<iostream>

int main(void) {
	uint32 n;
	std::cin >> n;
	std::vector<int64> a(n);
	for (uint32 i = 0;i < n;++i)std::cin >> a[i];
	int64 max = a[0];
	uint32 getmax=0;
	for (uint32 i = 1;i < n;++i) {
		if (max < a[i]) {
			max = a[i];
			getmax = i;
		}
	}
	if (max < 0) {
		std::cout << max << "\n" << n - 1<<"\n";
		for (uint32 i = n - 1;i != getmax;--i) {
			std::cout << i+1 << "\n";
		}
		for (uint32 i = 0;i !=getmax;++i) {
			std::cout << "1\n";
		}
		
		return 0;
	}
	std::vector<char> u(n, 0);
	int64 o = 0, e = 0;
	for (uint32 i = 0;i < n;i += 2) {
		e += std::max(a[i], (int64)0);
	}
	for (uint32 i = 1;i < n;i += 2) {
		o += std::max(a[i], (int64)0);
	}
	if (o <= e) {
		for (uint32 i = 0;i < n;i += 2) {
			if (a[i] >= (int64)0)u[i] = 1;
		}
	}
	else {
		for (uint32 i = 1;i < n;i += 2) {
			if (a[i] >= (int64)0)u[i] = 1;
		}
	}
	std::cout << std::max(o, e) << "\n";
	std::vector<uint32> q;
	uint32 eit;
	eit = n - 1;
	while (u[eit]==0) {
		q.push_back(eit + 1);
		--eit;
	}
	uint32 bit = 0;
	while (u[bit]==0) {
		q.push_back(1);
		++bit;
	}
	uint32 nitr=0;
	++bit;
	while (bit<eit) {
		if (u[bit + 1]==1) {
			q.push_back(2);
			bit += 2;
		}
		else {
			q.push_back(3);
			bit += 2;
		}
	}
	std::cout << q.size() << "\n";
	for (uint32 i = 0;i < q.size();++i) {
		std::cout << q[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 256