#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
int main() {
  std::ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<long long> v(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  vector<int> rs;
  long long sm;
  long long mx = -1000000000ll * 1000000ll;
  vector<int> frs;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      if (v[i] == v[j]) {
        rs.clear();
        sm = 0;
        for (int k = 0; k < n; ++k) {
          if (k < i || k > j) rs.push_back(k);
          if (k == i || k == j) sm += v[k];
          if (k > i && k < j) {
            if (v[k] < 0)
              rs.push_back(k);
            else
              sm += v[k];
          }
        }
        if (mx < sm) {
          mx = sm;
          frs = rs;
        }
      }
    }
  }
  cout << mx << " " << int((frs).size()) << endl;
  if (int((frs).size()) == 0) return 0;
  cout << frs[0] + 1;
  for (int i = 1; i < int((frs).size()); ++i) {
    cout << " " << frs[i] + 1;
  }
  return 0;
}
