#include <bits/stdc++.h>
using namespace std;
const int inf = 1.01e9;
const double eps = 1e-9;
const int N = 3e5 + 10;
int a[N];
long long s[N];
map<int, int> fst;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; (i) < (n); ++i) scanf("%d", &a[i]);
  for (int i = 0; (i) < (n); ++i) s[i + 1] = s[i] + max(0, a[i]);
  long long res = -1e18;
  int resl = 0, resr = 0;
  for (int i = 0; (i) < (n); ++i) {
    if (fst.find(a[i]) == fst.end()) {
      fst[a[i]] = i;
    } else {
      long long val = s[i] - s[fst[a[i]] + 1] + a[i] * 2;
      if (val > res) {
        res = val;
        resl = fst[a[i]];
        resr = i;
      }
    }
  }
  vector<int> v;
  for (int i = 0; (i) < (resl); ++i) v.push_back(i);
  for (int i = resl + 1; i < resr; ++i)
    if (a[i] <= 0) v.push_back(i);
  for (int i = resr + 1; i < n; ++i) v.push_back(i);
  printf("%I64d %d\n", res, ((int)(v).size()));
  for (int i = 0; (i) < (((int)(v).size())); ++i)
    printf("%d%c", v[i] + 1, " \n"[i + 1 == ((int)(v).size())]);
  return 0;
}
