#include <bits/stdc++.h>
using namespace std;
int n;
long long ans = -111111111111;
map<int, int> flag;
int cut[300005];
long long asum[300006];
int a[300006];
map<int, vector<int> > mp;
map<int, vector<int> >::iterator it;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int main() {
  n = read();
  int l = 1, r = 2;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    if (a[i] > 0)
      asum[i] = asum[i - 1] + a[i];
    else
      asum[i] = asum[i - 1];
    if (flag[a[i]] == 0)
      flag[a[i]] = i;
    else {
      long long gapsum = asum[i] - asum[flag[a[i]] - 1];
      if (a[i] < 0) gapsum += 2 * a[i];
      if (ans < gapsum) {
        ans = gapsum;
        l = flag[a[i]];
        r = i;
      }
    }
  }
  int k = 0;
  for (int i = 1; i < l; i++) cut[++k] = i;
  for (int i = l + 1; i < r; i++)
    if (a[i] < 0) cut[++k] = i;
  for (int i = r + 1; i <= n; i++) cut[++k] = i;
  printf("%lld %d\n", ans, k);
  for (int i = 1; i <= k; i++) printf("%d ", cut[i]);
}
