#include <bits/stdc++.h>
using namespace std;
map<long long, int> st;
map<long long, int> ed;
map<long long, int> vis;
long long a[500010];
long long sum[500010];
int main() {
  int n;
  scanf("%d", &n);
  int l = 0, r = 0;
  long long ans = -10000000000000000ll;
  sum[0] = 0;
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 1; i <= n; i++) {
    if (a[i] < 0)
      sum[i] = sum[i - 1];
    else
      sum[i] = sum[i - 1] + a[i];
    if (st[a[i]] == 0) st[a[i]] = i;
    ed[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (ed[a[i]] != st[a[i]]) {
      if (a[i] * 2 + sum[ed[a[i]] - 1] - sum[st[a[i]]] > ans) {
        ans = a[i] * 2 + sum[ed[a[i]] - 1] - sum[st[a[i]]];
        l = st[a[i]];
        r = ed[a[i]];
      }
    }
  }
  int k = 0;
  bool first = true;
  for (int i = 1; i <= n; i++) {
    if (i < l || i > r)
      k++;
    else if (i > l && i < r) {
      if (a[i] < 0) k++;
    }
  }
  cout << ans << " " << k << endl;
  first = true;
  for (int i = 1; i <= n; i++) {
    if (i < l || i > r) {
      if (first)
        printf("%d", i);
      else
        printf(" %d", i);
      first = false;
    } else if (i > l && i < r) {
      if (a[i] < 0) {
        if (first)
          printf("%d", i);
        else
          printf(" %d", i);
        first = false;
      }
    }
  }
  if (!first) puts("");
}
