#include <bits/stdc++.h>
using namespace std;
long long int a[110];
long long int f[110];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    f[i] = f[i - 1];
    if (a[i] >= 0) {
      f[i] += a[i];
    }
  }
  long long int ans = -1000000000000000;
  int lf, rt;
  for (int i = 1; i <= n; i++) {
    for (int j = i - 1; j >= 1; j--) {
      if (a[i] == a[j]) {
        int temp = 0;
        if (a[i] < 0) {
          temp = 2 * a[i];
        }
        ans = max(ans, f[i] - f[j - 1] + temp);
        if (ans == f[i] - f[j - 1] + temp) {
          lf = j;
          rt = i;
        }
      }
    }
  }
  cout << ans << " ";
  vector<int> res;
  for (int i = lf + 1; i < rt; i++) {
    if (a[i] < 0) res.push_back(i);
  }
  for (int i = lf - 1; i >= 1; i--) {
    res.push_back(i);
  }
  for (int i = rt + 1; i <= n; i++) {
    res.push_back(i);
  }
  int k = res.size();
  cout << k << endl;
  for (int i = 0; i < k; i++) {
    cout << res[i] << " ";
  }
  cout << endl;
  return 0;
}
