#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10, INFTY = 1e10;
long long tutti[300005], negativi[300005];
map<long long, pair<long long, long long> > M;
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    long long v;
    cin >> v;
    if (i) tutti[i] = tutti[i - 1], negativi[i] = negativi[i - 1];
    tutti[i] += v;
    if (v < 0) negativi[i] += -v;
    if (M.count(v))
      M[v].second = i;
    else
      M[v] = pair<long long, long long>(i, -1);
  }
  long long best = -LONG_LONG_MAX;
  pair<long long, long long> bestpos = pair<long long, long long>(-1, -1);
  for (map<long long, pair<long long, long long> >::const_iterator it =
           M.begin();
       it != M.end(); it++) {
    pair<long long, long long> pos = it->second;
    if (pos.second == -1) continue;
    long long res =
        (tutti[pos.second] - (pos.first ? tutti[pos.first - 1] : 0));
    if (pos.second != pos.first + 1)
      res += (negativi[pos.second - 1] - negativi[pos.first]);
    if (res > best) {
      best = res;
      bestpos = pos;
    }
  }
  vector<int> ans;
  for (int i = 0; i < bestpos.first; i++) ans.push_back(i + 1);
  for (int i = bestpos.second + 1; i < N; i++) ans.push_back(i + 1);
  for (int i = bestpos.first + 1; i < bestpos.second; i++)
    if (negativi[i] - negativi[i - 1] > 0) ans.push_back(i + 1);
  cout << best << " " << ans.size() << endl;
  for (int i = 0; i < (int)ans.size(); i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
