#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n;
long long sum[3000010];
int A[3000010], mi[3000010], mx[3000010], V[3000010], Ans[3000010];
map<int, int> M;
int main() {
  n = read();
  for (int i = 1; i <= n; i++) A[i] = read(), V[++V[0]] = A[i];
  sort(V + 1, V + 1 + V[0]);
  V[0] = unique(V + 1, V + 1 + V[0]) - V - 1;
  for (int i = 1; i <= n; i++) sum[i] += sum[i - 1] + max(0, A[i]);
  for (int i = 1; i <= V[0]; i++) M[V[i]] = i;
  for (int i = 1; i <= n; i++) mi[i] = 3000010 + 10;
  for (int i = 1; i <= n; i++) mi[M[A[i]]] = min(i, mi[M[A[i]]]);
  for (int i = 1; i <= n; i++) mx[M[A[i]]] = max(i, mx[M[A[i]]]);
  int ps = 0;
  for (int i = 1; i <= V[0]; i++) {
    if (mi[i] == mx[i]) continue;
    if (ps == 0)
      ps = i;
    else {
      if (sum[mx[ps]] - sum[mi[ps] - 1] + (A[mi[ps]] < 0 ? A[mi[ps]] : 0) * 2 <
          sum[mx[i]] - sum[mi[i] - 1] + (A[mi[i]] < 0 ? A[mi[i]] : 0) * 2)
        ps = i;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (i < mi[ps] || i > mx[ps] || (A[i] < 0 && i != mi[ps] && i != mx[ps]))
      cnt++, Ans[cnt] = i;
  cout << sum[mx[ps]] - sum[mi[ps] - 1] + (A[mi[ps]] < 0 ? A[mi[ps]] : 0) * 2
       << " " << cnt << endl;
  for (int i = 1; i <= cnt; i++) printf("%d ", Ans[i]);
}
