#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;
int n, a[300000];
long long sum[300001];
int main() {
  map<int, int> pos;
  set<int> er;
  scanf("%d", &n);
  for (int i = 0; i < (int)n; i++) {
    scanf("%d", a + i);
    sum[i + 1] = sum[i] + max(0, a[i]);
    pos[a[i]] = i;
  }
  long long best = -(long long)1e18;
  int besti = -1;
  for (int i = 0; i < (int)n; i++) {
    if (pos[a[i]] <= i) continue;
    long long tmp = sum[pos[a[i]] + 1] - sum[i];
    if (a[i] < 0) tmp += 2 * a[i];
    if (best < tmp) best = tmp, besti = i;
  }
  int r = pos[a[besti]];
  for (int i = 0; i < (int)n; i++) {
    if (i < besti || i > r) {
      er.insert(i);
      continue;
    }
    if (besti < i && i < r && a[i] < 0) er.insert(i);
  }
  cout << best << " " << er.size() << endl;
  for (__typeof(er.begin()) i = er.begin(); i != er.end(); i++)
    cout << (i == er.begin() ? "" : " ") << *i + 1;
  cout << endl;
  return 0;
}
