#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const ll INF = TEN(18);

int main() {
    int N;
    cin >> N;
    V<int> a(N);
    rep(i, N) cin >> a[i];
    ll maxi = -INF;
    V<int> ids;
    rep(t, 2) {
        V<pair<ll, int>> vec;
        rep(i, N) {
            if (i % 2 == t) {
                vec.eb(a[i], i);
            }
        }
        sort(ALL(vec));
        reverse(ALL(vec));
        int k = 0;
        ll s = vec[0].fi, m = s;
        for (int i = 1; i < vec.size(); ++i) {
            m += vec[i].fi;
            if (m > s) {
                s = m;
                k = i;
            }
        }
        V<int> use;
        for (int i = 0; i <= k; ++i) {
            use.pb(vec[i].se);
        }
        if (s > maxi) {
            maxi = s;
            ids = use;
        }
    }
    debug(maxi, ids);
    V<bool> use(N);
    for (int p : ids) use[p] = true;
    int l = 0, r = N - 1;
    V<int> rem(N);
    iota(ALL(rem), 0);

    V<int> ope;

    while (rem.size() > 1) {
        int p = -1;
        V<int> nx;

        if (!use[rem[0]]) {
            p = 0;
        } else if (!use[rem.back()]) {
            p = rem.size() - 1;
        } else {
            for (int k = 1; k + 1 < rem.size(); ++k) {
                if (!use[rem[k - 1]] && !use[rem[k]] && !use[rem[k + 1]]) {
                    p = k;
                    break;
                }
            }
            if (p == -1) {
                for (int k = 1; k + 1 < rem.size(); ++k) {
                    if (use[rem[k - 1]] && !use[rem[k]] && use[rem[k + 1]]) {
                        p = k;
                        break;
                    }
                }
            }
        }

        ope.pb(p);
        debug(p);
        if (p == -1) return -1;
        {
            V<int> nx;
            if (p == 0 || p == rem.size() - 1) {
                rep(i, rem.size()) if (i != p) nx.pb(rem[i]);
            } else {
                rep(i, p) { nx.pb(rem[i]); }
                for (int i = p + 2; i < rem.size(); ++i) {
                    nx.pb(rem[i]);
                }
            }
            rem = nx;
        }
    }

    cout << maxi << endl;
    cout << ope.size() << endl;
    for (int x : ope) {
        cout << x + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 764