#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    bool F = true;
    rep(i, n) if (a[i] > 0) F = false;
    if (F)
    {
        int MAX = -INF;
        rep(i, n) MAX = max(MAX, a[i]);
        cout << MAX << endl;
        cout << n - 1 << endl;
        rep(i, n)
        {
            if (MAX != a[i])
                cout << 1 << endl;
            else
            {
                for (int j = n - i - 1; j > 0; j--)
                    cout << j + 1 << endl;
                return 0;
            }
        }
    }
    vector<int> v(n), w(n);
    rep(i, n)
    {
        if (i % 2)
            v[i] = max(a[i], 0LL);
        else
            w[i] = max(a[i], 0LL);
    }
    vector<int> sum1(n + 1), sum2(n + 1);
    rep(i, n)
    {
        sum1[i + 1] = sum1[i] + v[i];
        sum2[i + 1] = sum2[i] + w[i];
    }
    int ans = 0;
    bool f = true;
    rep(i, n)
    {
        Rep(j, i, n)
        {
            int tmp = max(sum1[j + 1] - sum1[i], sum2[j + 1] - sum2[i]);
            if (ans < tmp)
            {
                ans = tmp;
                f = (tmp == sum1[j + 1] - sum1[i]);
            }
        }
    }
    vector<bool> vf(n);
    rep(i, n) vf[i] = true;
    if (f)
        for (int i = 0; i < n; i += 2)
            vf[i] = false;
    else
        for (int i = 1; i < n; i += 2)
            vf[i] = false;
    rep(i, n) if (a[i] < 0) vf[i] = false;
    int s = 0, sz = n;
    vector<int> b;
    vector<bool> used(n);
    while (sz > 1)
    {
        int pos = 0, pre = -1, nxt = -1;
        for (int i = 0; i < n; i++)
        {
            if (used[i])
                continue;
            pos++;
            if (!vf[i])
            {
                if (pos == 1 || pos == sz)
                {
                    b.push_back(pos);
                    used[i] = true;
                    sz--;
                    break;
                }
                for (int j = i + 1; j < n; j++)
                    if (!used[j])
                    {
                        nxt = j;
                        break;
                    }
                if (vf[pre] && vf[nxt])
                {
                    b.push_back(pos);
                    used[pre] = true;
                    used[nxt] = true;
                    vf[i] = true;
                    vf[pre] = false;
                    vf[nxt] = false;
                    sz -= 2;
                    i = nxt - 1;
                    break;
                }
                if (!vf[pre] && !vf[nxt])
                {
                    b.push_back(pos);
                    used[pre] = true;
                    used[nxt] = true;
                    vf[pre] = false;
                    vf[nxt] = false;
                    sz -= 2;
                    i = nxt - 1;
                    break;
                }
            }
            pre = i;
        }
    }
    cout << ans << endl;
    cout << b.size() << endl;
    rep(i, b.size()) cout << b[i] << endl;
}

Measured memory_bytes: 256