#include <bits/stdc++.h>
using namespace std;
const int maxN = 3 * 100000 + 10;
long long A[maxN];
int N;
long long sum[maxN];
struct node {
  long long val;
  int idx;
  inline bool operator<(const node &s) const {
    if (val != s.val) return val < s.val;
    return idx < s.idx;
  }
};
node B[maxN];
int main() {
  scanf("%d", &N);
  A[0] = 0LL;
  for (int i = 1; i <= N; i++) scanf("%I64d", A + i);
  sum[0] = 0LL;
  for (int i = 1; i <= N; i++) {
    if (A[i] >= 0)
      sum[i] = sum[i - 1] + A[i];
    else
      sum[i] = sum[i - 1];
  }
  for (int i = 1; i <= N; i++) {
    B[i].idx = i;
    B[i].val = A[i];
  }
  sort(B + 1, B + 1 + N);
  int resL = -1, resR = -1;
  long long res = -10000000000000000LL;
  long long tmp;
  int l, r, m, pos;
  for (int i = 1; i <= N; i++) {
    l = 1;
    r = N;
    pos = -1;
    while (l <= r) {
      m = (l + r) >> 1;
      if (B[m].val < A[i])
        l = m + 1;
      else if (B[m].val > A[i])
        r = m - 1;
      else {
        pos = B[m].idx;
        l = m + 1;
      }
    }
    if (pos != -1 && pos != i) {
      tmp = sum[pos] - sum[i - 1];
      if (A[i] < 0) tmp += 2LL * A[i];
      if (res < tmp) {
        res = tmp;
        resL = i;
        resR = pos;
      }
    }
  }
  int tot = 2;
  for (int i = resL + 1; i < resR; i++) tot += (A[i] >= 0);
  printf("%I64d", res);
  printf(" %d\n", N - tot);
  bool sgn = 0;
  for (int i = 1; i < resL; i++) {
    if (sgn)
      putchar(' ');
    else
      sgn = 1;
    printf("%d", i);
  }
  for (int i = resL + 1; i < resR; i++) {
    if (A[i] >= 0) continue;
    if (sgn)
      putchar(' ');
    else
      sgn = 1;
    printf("%d", i);
  }
  for (int i = resR + 1; i <= N; i++) {
    if (sgn)
      putchar(' ');
    else
      sgn = 1;
    printf("%d", i);
  }
  putchar('\n');
  return 0;
}
