#include <bits/stdc++.h>
using namespace std;
long long x[300100], z[300100], kd[300100];
pair<long long, long long> y[300100];
int main() {
  long long n, i, f;
  scanf("%I64d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &y[i].first);
    y[i].second = i;
    z[i] = y[i].first;
    if (z[i] > 0) {
      kd[i] = kd[i - 1] + 1;
      x[i] = x[i - 1] + y[i].first;
    } else {
      kd[i] = kd[i - 1];
      x[i] = x[i - 1];
    }
  }
  sort(&y[1], &y[n + 1]);
  long long o = -20000000000ll, lo, ro;
  for (i = 1; i <= n; i++) {
    f = i;
    while (y[i + 1].first == y[f].first && i < n) {
      i++;
    }
    if (i != f) {
      if (o < x[y[i].second - 1] - x[y[f].second] + y[f].first * 2) {
        o = x[y[i].second - 1] - x[y[f].second] + y[f].first * 2;
        lo = y[f].second;
        ro = y[i].second;
      }
    }
  }
  printf("%I64d %I64d\n", o,
         n - (ro - lo + 1) + ((ro - lo - 1) - kd[ro - 1] + kd[lo]));
  for (i = 1; i <= n; i++)
    if (i < lo || i > ro) {
      printf("%I64d ", i);
    } else if (i > lo && i < ro && z[i] <= 0) {
      printf("%I64d ", i);
    }
}
