#include <bits/stdc++.h>
using namespace std;
int a[300001], s[300001];
void qs(int q, int w) {
  int e = q, r = w, y = q + (rand() % (w - q + 1)), t = a[y];
  do {
    while (a[e] < t) e++;
    while (a[r] > t) r--;
    if (e <= r) {
      y = a[e];
      a[e] = a[r];
      a[r] = y;
      y = s[e];
      s[e] = s[r];
      s[r] = y;
      e++;
      r--;
    }
  } while (e <= r);
  if (q < r) qs(q, r);
  if (e < w) qs(e, w);
}
int main() {
  int q, w, e, r, c, v, y, u, f[300001];
  long long t = -2000000001, *d = new long long[300001];
  scanf("%d", &q);
  d[0] = 0;
  for (w = 1; w <= q; w++) {
    scanf("%d", &a[w]);
    s[w] = w;
    d[w] = max(0, a[w]);
    d[w] += d[w - 1];
    f[w] = a[w];
  }
  qs(1, q);
  for (w = 1; w <= q; w = e) {
    c = v = s[w];
    for (e = w + 1; (e <= q) && (a[w] == a[e]); e++) {
      c = min(c, s[e]);
      v = max(v, s[e]);
    }
    if (e == w + 1) continue;
    if (t < (a[w] << 1) + d[v - 1] - d[c]) {
      t = (a[w] << 1) + d[v - 1] - d[c];
      y = c;
      u = v;
    }
  }
  cout << t << " ";
  r = y - 1 + q - u;
  for (w = y + 1; w < u; w++)
    if (f[w] < 0) r++;
  cout << r << "\n";
  for (w = 1; w < y; w++) printf("%d ", w);
  for (w = y + 1; w < u; w++)
    if (f[w] < 0) printf("%d ", w);
  for (w = u + 1; w <= q; w++) printf("%d ", w);
  return 0;
}
