#include <bits/stdc++.h>
using namespace std;
template <class T>
void print(vector<T> v) {
  cerr << "[";
  if (v.size()) cerr << v[0];
  for (int i = (1); i < (v.size()); ++i) cerr << ", " << v[i];
  cerr << "]\n";
}
template <class T>
string i2s(T x) {
  ostringstream o;
  o << x;
  return o.str();
}
vector<string> splt(string s, char c = ' ') {
  vector<string> all;
  int p = 0, np;
  while (np = s.find(c, p), np >= 0) {
    if (np != p) all.push_back(s.substr(p, np - p));
    p = np + 1;
  }
  if (p < s.size()) all.push_back(s.substr(p));
  return all;
}
int x[1001000];
map<long long, pair<long long, long long> > ff;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &x[i]);
  long long sum = 0;
  long long rv = -(1LL << 60);
  long long ba, bb;
  for (int i = (0); i < (n); ++i) {
    sum += max(0, x[i]);
    if (ff.count(x[i]) == 0) {
      ff[x[i]] = make_pair(sum - max(0, x[i]), i);
    } else {
      long long av = sum - ff[x[i]].first;
      if (x[i] < 0) av += 2 * x[i];
      if (av > rv) {
        rv = av;
        ba = ff[x[i]].second;
        bb = i;
      }
    }
  }
  vector<int> p;
  for (int i = (0); i < (n); ++i)
    if (i < ba || i > bb || i != ba && i != bb && x[i] < 0) p.push_back(i);
  cout << rv << ' ' << p.size() << endl;
  for (int i = (0); i < (p.size()); ++i) printf("%d ", p[i] + 1);
  cout << endl;
}
