// Copyright (C) 2018 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


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

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    #define int int64_t
    // code here.
    int n = input<int>();
    vector<int> a(n);
    input_seq(ALL(a));

    vector<int> dp(n);

    for (int i = 0; i != n; ++i) {
        int best_prev = 0;
        for (int j = i - 2; j >= 0; j -= 2)
            best_prev = max(best_prev, dp[j]);
        
        dp[i] = (a[i] + best_prev);
    }

    int pmx = std::max_element(ALL(dp)) - dp.begin();

    vector<int> seq;
    for (int cur = pmx; cur != -1;) {
        seq.push_back(cur);
        int next = -1;
        
        for (int j = cur - 2; j >= 0; j -= 2)
            if (dp[cur] == a[cur] + dp[j])
                next = j;

        cur = next;
    }

    std::reverse(ALL(seq));

    vector<int> ans;
    for (int i = n - 1; i > seq.back(); --i)
        ans.pb(i);

    for (int i = SZ(seq) - 2; i >= 0; --i) {
        int a = seq[i], b = seq[i + 1];

        while (b - a != 2) {
            ans.pb(b - 2);
            b -= 2;
        }

        ans.pb(a + 1);
    }

    for (int i = 0; i < seq[0]; ++i)
        ans.pb(0);

    cout << dp[pmx] << "\n";
    cout << SZ(ans) << "\n";
    for (auto elem: ans)
        cout << elem + 1 << "\n";
    
    return 0;
}


Measured memory_bytes: 256