#include <bits/stdc++.h>
using namespace std;
int n;
long long maxim;
long long a[111];
int b[111];
int main() {
  long long s;
  int num = 2;
  maxim = -2000000001LL;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n - 1; i++)
    for (int j = i + 1; j <= n; j++)
      if (a[i] == a[j]) {
        s = 0;
        for (int k = i; k <= j; k++)
          if ((a[k] > 0) && (k > i) && (k < j) || (k == i) || (k == j))
            s += a[k];
        if (s >= maxim) {
          maxim = s;
          num = 0;
          for (int k = 1; k <= n; k++) {
            b[k] = 0;
            if (k < i || k > j || ((a[k] < 0) && (k > i) && (k < j))) {
              b[k] = 1;
              num++;
            }
          }
        }
      }
  cout << maxim << ' ' << num << endl;
  for (int i = 1; i <= n; i++)
    if (b[i] == 1) cout << i << ' ';
  return 0;
}
