#include <bits/stdc++.h>
using namespace std;
long long a[300005], s[300005];
int main() {
  ifstream inf("input.txt");
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  s[0] = 0;
  for (int i = 1; i <= n; i++)
    if (a[i] > 0)
      s[i] = s[i - 1] + a[i];
    else
      s[i] = s[i - 1];
  map<long long, long long> ma, mi;
  for (int i = 1; i <= n; i++)
    if (mi.count(a[i]) == 0) mi[a[i]] = i;
  for (int i = n; i > 0; i--)
    if (ma.count(a[i]) == 0) ma[a[i]] = i;
  long long j = -2000000001, b, e, f = 0;
  for (int i = 1; i <= n; i++) {
    long long h = s[ma[a[i]]] - s[mi[a[i]] - 1];
    if (a[i] < 0) h += 2 * a[i];
    if (mi[a[i]] != ma[a[i]] && h > j) {
      j = h;
      b = mi[a[i]];
      e = ma[a[i]];
    }
  }
  cout << j << ' ';
  for (int i = b + 1; i <= e - 1; i++)
    if (a[i] < 0) f++;
  cout << b - 1 + (n - e) + f << endl;
  for (int i = b + 1; i <= e - 1; i++)
    if (a[i] < 0) cout << i << ' ';
  for (int i = 1; i <= b - 1; i++) cout << i << ' ';
  for (int i = e + 1; i <= n; i++) cout << i << ' ';
}
