#include <bits/stdc++.h>
using namespace std;
int N;
int a[300010];
long long sum[300010];
map<int, int> minsum;
int main(void) {
  int i, j, p, q;
  cin >> N;
  for ((i) = 0; (i) < (int)(N); (i)++) scanf("%d", &a[i]);
  for ((i) = 0; (i) < (int)(N); (i)++)
    sum[i + 1] = sum[i] + ((a[i] > 0) ? a[i] : 0);
  int ansp = -1, ansq = -1;
  long long ans = -(1ll << 60);
  for ((q) = 0; (q) < (int)(N); (q)++) {
    if (minsum.find(a[q]) != minsum.end()) {
      p = minsum[a[q]];
      if (sum[q] - sum[p] + a[p] + ((a[p] > 0) ? 0 : a[p]) > ans) {
        ans = sum[q] - sum[p] + a[p] + ((a[p] > 0) ? 0 : a[p]);
        ansp = p;
        ansq = q;
      }
    }
    if (minsum.find(a[q]) == minsum.end() || sum[minsum[a[q]]] > sum[q])
      minsum[a[q]] = q;
  }
  int cut = 0;
  for ((i) = 0; (i) < (int)(N); (i)++)
    if (i < ansp || i > ansq || (i > ansp && i < ansq && a[i] < 0)) cut++;
  cout << ans << ' ' << cut << endl;
  for ((i) = 0; (i) < (int)(N); (i)++)
    if (i < ansp || i > ansq || (i > ansp && i < ansq && a[i] < 0)) {
      printf("%d", i + 1);
      cut--;
      if (cut == 0)
        printf("\n");
      else
        printf(" ");
    }
  return 0;
}
