#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, u, j, s, maxSum = -2000000001, num1 = -1, num2 = -1;
  cin >> n;
  vector<int> a(n);
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    for (j = n - 1; j > i; j--) {
      if (a[i] == a[j]) {
        s = 0;
        for (u = i; u <= j; u++)
          if (a[u] > 0 || u == i || u == j) s += a[u];
        if (s > maxSum) {
          maxSum = s;
          num1 = i;
          num2 = j;
          break;
        }
      }
    }
  }
  cout << maxSum << ' ';
  vector<int> min;
  for (u = num1 + 1; u < num2; u++)
    if (a[u] < 0) min.push_back(u);
  cout << num1 + n - 1 - num2 + min.size() << '\n';
  for (u = 0; u < num1; u++) cout << u + 1 << ' ';
  for (u = 0; u < min.size(); u++) cout << min[u] + 1 << ' ';
  for (u = num2 + 1; u < n; u++) cout << u + 1 << ' ';
  return 0;
}
