#include <bits/stdc++.h>
using namespace std;
int n, a[1009];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  if (*max_element(a, a + n) <= 0) {
    int ptr = max_element(a, a + n) - a;
    cout << a[ptr] << endl;
    ptr++;
    cout << n - 1 << endl;
    for (int i = n; i > ptr; i--) cout << i << endl;
    for (int i = 1; i < ptr; i++) cout << 1 << endl;
  } else {
    vector<int> v;
    long long cs = 0;
    for (int i = 0; i < 2; i++) {
      long long ss = 0;
      vector<int> sv;
      for (int j = i; j < n; j += 2) {
        if (a[j] > 0) ss += a[j], sv.push_back(j + 1);
      }
      if (ss > cs) {
        cs = ss;
        v = sv;
      }
    }
    vector<int> seq;
    for (int i = n; i > v.back(); i--) seq.push_back(i);
    for (int i = (int)v.size() - 2; i >= 0; i--) {
      for (int j = (v[i] + v[i + 1]) / 2; j > v[i] + 1; j--) {
        seq.push_back(j);
      }
    }
    for (int i = 1; i < v.front(); i++) seq.push_back(1);
    for (int i = 0; i < (int)v.size() - 1; i++) seq.push_back(2);
    cout << cs << endl;
    cout << seq.size() << endl;
    for (int i : seq) cout << i << endl;
  }
  return 0;
}
