#include <bits/stdc++.h>
using namespace std;
int n, i;
long long f[300030], g[300030], cnt[300030];
struct xx {
  int x, n;
} a[300030];
bool cmp(xx a, xx b) { return a.x < b.x || (a.x == b.x && a.n < b.n); }
int main() {
  scanf("%d", &n);
  f[0] = g[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].x);
    a[i].n = i;
    f[i] = f[i - 1] + a[i].x;
    g[i] = g[i - 1];
    cnt[i] = cnt[i - 1];
    if (a[i].x < 0) {
      g[i] += -a[i].x;
      cnt[i]++;
    }
  }
  sort(a + 1, a + n + 1, cmp);
  i = 1;
  int st, ed, v, ansst, ansed;
  long long ans = -10000000000000ll, temp;
  while (i <= n) {
    st = a[i].n;
    v = a[i].x;
    while (a[i + 1].x == a[i].x && i < n) i++;
    ed = a[i].n;
    if (st == ed) {
      i++;
      continue;
    }
    temp = f[ed - 1] - f[st] + g[ed - 1] - g[st] + v * 2;
    if (temp > ans) {
      ans = temp;
      ansst = st;
      ansed = ed;
    }
    i++;
  }
  long long u = cnt[ansed - 1] - cnt[ansst] + n - ansed + ansst - 1;
  printf("%I64d ", ans);
  printf("%I64d\n", u);
  for (int i = 1; i <= n; i++) {
    if ((a[i].x < 0 || a[i].n < ansst || a[i].n > ansed) && a[i].n != ansst &&
        a[i].n != ansed)
      printf("%d ", a[i].n);
  }
}
