#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<long long> a(n);
        long long even = 0, odd = 0;
        bool all_neg = true;
        for (int i = 0; i < n; i ++) {
                scanf("%lld", &a[i]);
                all_neg = all_neg && a[i] < 0;
                if (i & 1) {
                        odd += max(0LL, a[i]);
                } else {
                        even += max(0LL, a[i]);
                }
        }
        vector<int> ans;
        if (all_neg) {
                long long ma = -10000000000000LL;
                int mai = -1;
                for (int i = 0; i < n; i ++) {
                        if (ma < a[i]) {
                                ma = a[i];
                                mai = i;
                        }
                }
                int mn = mai;
                while (mn --) {
                        ans.push_back(1);
                }
                mn = n - mai - 1;
                while (mn --) {
                        ans.push_back(mn + 2);
                }
                printf("%lld\n", ma);
        } else {
                printf("%lld\n", max(even, odd));
                bool is_even = even >= odd;
		bool fuga = false;
                if (is_even && a[0] < 0) {
                        is_even = false;
			fuga = true;
                        auto b = a;
                        a.clear();
                        for (int i = 1; i < n; i ++) {
                                a.push_back(b[i]);
                        }
                        n --;
                        ans.push_back(1);
                }
                if (is_even) {
                        vector<long long> hoge;
                        for (int i = 0; i < n; i ++) {
                                if (i % 2 == 0 && a[i] < 0) {
                                        ans.push_back(i + 1 - (int) ans.size() * 2);
					if (i != n - 1) {
						hoge.pop_back();
					}
                                } else {
                                        hoge.push_back(a[i]);
                                }
                        }
                        int hn = (int) hoge.size() / 2;
                        while(hn --) {
                                ans.push_back(2);
                        }
                } else {
                        vector<long long> hoge;
                        for (int i = 0; i < n; i ++) {
                                if (i & 1 && a[i] < 0) {
                                        ans.push_back(i + 1 - ((int) ans.size() - fuga) * 2);
					if (i != n - 1) {
						hoge.pop_back();
					}
                                } else {
                                        hoge.push_back(a[i]);
                                }
                        }
                        int hn = ((int) hoge.size() - 1) / 2;
                        ans.push_back(1);
                        while (hn --) {
                                ans.push_back(2);
                        }
                }
        }
        printf("%d\n", (int) ans.size());
        for (int i = 0; i < (int) ans.size(); i ++) {
                printf("%d\n", ans[i]);
        }
        return 0;
}



Measured memory_bytes: 256