#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>
#include <unordered_set>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const long long INF = 1e18;
#define int long long
const long long MOD = 998244353;

int n;
long long a[5000];
long long val1, val2;

void printer(vector<int> q)
{
    long long res = 0;
    for (int i = 0; i < q.size(); i++) res += q[i] * a[i];
    cout << res << "\n";
    vector<int> ans;
    for (int i = n; i >= 1; i--)
    {
        if (q[i] == 0)
        {
            ans.push_back(i);
        }
        else
        {
            int l = i - 1;
            while (l > 0 && q[l] != 1)
            {
                l--;
            }
            if (l == 0)
            {
                for (int j = i - 1; j >= 1; j--) ans.push_back(1);
            }
            else
            {
                int m = (l + i) / 2;
                for (int j = m; j > l; j--) ans.push_back(j);
            }
            i = l + 1;
        }
    }
    cout << ans.size() << "\n";
    for (auto e : ans) cout << e << " ";
    exit(0);
}

signed main()
{
    srand(time(NULL));
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) if (i % 2 == 0) val1 += max(0LL, a[i]); else val2 += max(0LL, a[i]);
    vector<int> q(n + 1);
    if (val1 > val2)
    {
        for (int i = 1; i <= n; i++) if (i % 2 == 0 && a[i] >= 0) q[i] = 1;
    }
    else
    {
        for (int i = 1; i <= n; i++) if (i % 2 == 1 && a[i] >= 0) q[i] = 1;
    }
    int cnt = 0;
    for (int i = 0; i < q.size(); i++) if (q[i]) cnt++;
    if (cnt == 0)
    {
        int mx = -1e9, ps = 0;
        for (int i = 1; i <= n; i++) if (a[i] > mx) mx = a[i], ps = i;
        q[ps] = 1;
    }
    printer(q);
}


Measured memory_bytes: 256