#include <bits/stdc++.h>
using namespace std;
vector<int> cut;
long long a[300005];
int main() {
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  bool first = true;
  long long Max = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (a[i] == a[j]) {
        long long sum = a[i] * 2;
        vector<int> now;
        for (int k = 0; k < i; k++) now.push_back(k + 1);
        for (int k = j + 1; k < n; k++) now.push_back(k + 1);
        for (int k = i + 1; k < j; k++)
          if (a[k] < 0)
            now.push_back(k + 1);
          else
            sum += a[k];
        if (first || sum > Max) {
          first = false;
          Max = sum;
          cut.clear();
          for (int i = 0; i < now.size(); i++) cut.push_back(now[i]);
        }
      }
  cout << Max << ' ' << cut.size() << endl;
  for (int i = 0; i < cut.size(); i++) cout << cut[i] << ' ';
  cout << endl;
  return 0;
}
