#include <bits/stdc++.h>

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<pair<LL, int>> a;
  Solver(LL n) : n(n), a(n){};

  void solve() {
    LL oddSum = 0, evenSum = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i].first;
      a[i].second = i % 2;
      if (a[i].first > 0) {
        if (i % 2) {
          oddSum += a[i].first;
        } else {
          evenSum += a[i].first;
        }
      }
    }
    DBG(evenSum, oddSum)
    vector<int> operation;
    if (max(evenSum, oddSum) <= 0) {
      int idx = distance(a.begin(), max_element(a.begin(), a.end()));
      DBG(idx)
      cout << a[idx].first << endl;
      cout << n - 1 << endl;
      int sz = n;
      for (int i = 0; i < idx; ++i) {
        cout << 1 << endl;
        sz--;
      }
      while (sz > 1) {
        cout << sz << endl;
        sz--;
      }
      return;
    }
    if (oddSum >= evenSum) {
      cout << oddSum << endl;
      while (1) {
        bool out = false;
        DBG(a)
        for (int i = 0; i < (int)a.size(); ++i) {
          if (a[i].first < 0 and a[i].second % 2 == 1) {
            if (i == 0 or i == (int)a.size() - 1) {
              operation.push_back(i);
              a.erase(a.begin() + i);
              break;
            } else {
              operation.push_back(i);
              a[i].second ^= 1;
              a[i].first = a[i - 1].first + a[i + 1].first;
              a.erase(a.begin() + i + 1);
              a.erase(a.begin() + i - 1);
              break;
            }
          }
          if (i == (int)a.size() - 1) out = true;
        }
        if (out) break;
      }
      for (int i = (int)a.size() - 1; i >= 0; --i) {
        if (a[i].second % 2 == 0) operation.push_back(i);
      }
    } else {
      cout << evenSum << endl;
      while (1) {
        bool out = false;
        for (int i = 0; i < (int)a.size(); ++i) {
          if (a[i].first < 0 and a[i].second % 2 == 0) {
            if (i == 0 or i == (int)a.size() - 1) {
              operation.push_back(i);
              a.erase(a.begin() + i);
              break;
            } else {
              operation.push_back(i);
              a[i].first = a[i - 1].first + a[i + 1].first;
              a[i].second ^= 1;
              a.erase(a.begin() + i + 1);
              a.erase(a.begin() + i - 1);
              break;
            }
          }
          if (i == (int)a.size() - 1) out = true;
        }
        if (out) break;
      }
      for (int i = (int)a.size() - 1; i >= 0; --i) {
        if (a[i].second % 2 == 1) operation.push_back(i);
      }
    }
    cout << (int)operation.size() << endl;
    for (int i = 0; i < (int)operation.size(); ++i) {
      cout << operation[i] + 1 << endl;
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 256