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