#include <bits/stdc++.h>
using namespace std;
long long a[200];
vector<int> q;
int main() {
  int n;
  cin >> n;
  int s, e;
  long long max = -1e12;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = 1; j < i; j++)
      if (a[j] == a[i]) {
        long long k = a[i] + a[j];
        for (int o = j + 1; o < i; o++)
          if (a[o] >= 0) k += a[o];
        if (k >= max) {
          s = j;
          e = i;
          max = k;
        }
      }
  }
  cout << max << " ";
  for (int i = s + 1; i < e; i++)
    if (a[i] < 0) q.push_back(i);
  for (int i = 1; i < s; i++) q.push_back(i);
  for (int i = e + 1; i <= n; i++) q.push_back(i);
  cout << q.size() << endl;
  for (int i = 0; i < q.size(); i++) cout << q[i] << " ";
  if (q.size()) cout << endl;
  return 0;
}
