#include <bits/stdc++.h>
using namespace std;
map<int, int> mina, maxa;
int main(void) {
  int n;
  mina[10] = 11;
  cin >> n;
  vector<long long> sum(n);
  vector<int> value(n);
  vector<int> ans;
  long long help;
  for (int i = 0; i < n; i++) {
    cin >> help;
    if (i > 0) sum[i] = sum[i - 1];
    if (help > 0) {
      sum[i] += help;
    }
    value[i] = help;
    if (mina.count(help) == 0) mina[help] = i;
    maxa[help] = i;
  }
  int la, ra;
  long long maxx = -10000000000000000LL;
  for (map<int, int>::iterator i = mina.begin(); i != mina.end(); i++) {
    if (maxa.count(i->first) > 0) {
      if (maxa[i->first] != i->second)
        if (value[i->second] * 2 + sum[maxa[i->first] - 1] - sum[i->second] >
            maxx) {
          maxx =
              value[i->second] * 2 + sum[maxa[i->first] - 1] - sum[i->second];
          la = i->second;
          ra = maxa[i->first];
        }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i < la)
      ans.push_back(i + 1);
    else if (i > ra)
      ans.push_back(i + 1);
    else if ((i == la) || (i == ra))
      continue;
    else if (value[i] < 0)
      ans.push_back(i + 1);
  }
  cout << maxx << " " << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}
