#include <bits/stdc++.h>
using namespace std;
const int MOD(1000000007);
const int INF((1 << 30) - 1);
const int MAXN(300005);
int a[MAXN];
map<int, pair<long long, int> > d;
int main() {
  int n, x = -1, y = n;
  scanf("%d", &n);
  long long sum = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (d.count(a[i])) {
      long long tmp = d[a[i]].first;
      int k = d[a[i]].second;
      if (x == -1 || sum - tmp + a[i] + a[i] > ans) {
        ans = sum - tmp + a[i] + a[i];
        x = k;
        y = i;
      }
      if (a[i] > 0) sum += a[i];
      d[a[i]] = min(d[a[i]], make_pair(sum, i));
    } else {
      if (a[i] > 0) sum += a[i];
      d[a[i]] = make_pair(sum, i);
    }
  }
  int cnt = n - (y - x + 1);
  for (int i = x + 1; i <= y - 1; i++)
    if (a[i] < 0) cnt++;
  printf("%I64d %d\n", ans, cnt);
  for (int i = 0; i <= x - 1; i++) printf("%d ", i + 1);
  for (int i = x + 1; i <= y - 1; i++)
    if (a[i] < 0) printf("%d ", i + 1);
  for (int i = y + 1; i <= n - 1; i++) printf("%d ", i + 1);
}
