#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int test_case;
  test_case = 1;
  while (test_case--) {
    long long int n;
    cin >> n;
    long long int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    vector<long long int> ans;
    long long int sum = 0, m = LLONG_MIN;
    for (int i = 0; i < n; i++) {
      for (int j = n - 1; j > i; j--) {
        if (a[i] == a[j]) {
          vector<long long int> v;
          for (int k = 0; k < n; k++) {
            if (k < i || k > j || (a[k] < 0 && k != i && k != j)) {
              v.push_back(k + 1);
            } else {
              sum += a[k];
            }
          }
          if (sum > m) {
            m = sum;
            ans = v;
          }
          sum = 0;
        }
      }
    }
    cout << m << " " << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
