#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e15;
struct ww {
  int a, id;
} b[300010];
int i, j, k, n, m, l, r, ll;
int a[300010];
long long ma, mi, c[300010];
inline bool cc1(const ww &a, const ww &b) {
  return a.a < b.a || a.a == b.a && a.id < b.id;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]), b[i].a = a[i], b[i].id = i;
    c[i] = c[i - 1] + (a[i] > 0) * a[i];
  }
  sort(b + 1, b + n + 1, cc1);
  ma = -inf;
  for (i = 1; i <= n; i++) {
    if (b[i].a == b[i - 1].a && i > 1) {
      long long an = c[b[i].id - 1] - mi + b[i].a * 2;
      if (an > ma) {
        ma = an;
        l = ll, r = b[i].id;
      }
    } else
      mi = inf;
    if (mi > c[b[i].id]) mi = c[b[i].id], ll = b[i].id;
  }
  printf("%I64d ", ma);
  int an = 0;
  for (i = 1; i <= l - 1; i++) an++;
  for (i = l + 1; i <= r - 1; i++)
    if (a[i] < 0) an++;
  for (i = r + 1; i <= n; i++) an++;
  printf("%d\n", an);
  for (i = 1; i <= l - 1; i++) printf("%d ", i);
  for (i = l + 1; i <= r - 1; i++)
    if (a[i] < 0) printf("%d ", i);
  for (i = r + 1; i <= n; i++) printf("%d ", i);
  printf("\n");
  return 0;
}
