#include <bits/stdc++.h>
using namespace std;
long long n, sum[300005], ori[300005], s[300005][2], ans, ansl, ansr, anscnt;
int comp(const void *a, const void *b) {
  long long *pa = (long long *)a, *pb = (long long *)b;
  if (pa[0] != pb[0])
    return pa[0] - pb[0];
  else
    return pa[1] - pb[1];
}
void checkoutans(int l, int r) {
  long long tem = sum[r + 1] - sum[l];
  if (ori[r] < 0) tem += ori[r] * 2;
  if (tem > ans) {
    ans = tem;
    ansl = l;
    ansr = r;
  }
  return;
}
int main() {
  long long i, j;
  scanf("%I64d", &n);
  sum[0] = 0;
  for (i = 0; i < n; i++) {
    scanf("%I64d", &ori[i]);
    s[i][0] = ori[i];
    s[i][1] = i;
    sum[i + 1] = sum[i];
    if (ori[i] > 0) sum[i + 1] += ori[i];
  }
  qsort(s, n, sizeof(long long) * 2, comp);
  ans = -LONG_LONG_MAX;
  for (j = 0, i = 1; i < n; i++)
    if (s[i][0] != s[j][0]) {
      if (i > j + 1) checkoutans(s[j][1], s[i - 1][1]);
      j = i;
    }
  if (j < n - 1) checkoutans(s[j][1], s[n - 1][1]);
  anscnt = ansl + n - ansr - 1;
  for (i = ansl + 1; i < ansr; i++)
    if (ori[i] < 0) anscnt++;
  printf("%I64d %I64d\n", ans, anscnt);
  for (i = 0; i < n; i++)
    if (i < ansl || i > ansr || (i != ansl && i != ansr && ori[i] < 0))
      printf("%I64d ", i + 1);
  printf("\n");
  return 0;
}
