#include <bits/stdc++.h>
using namespace std;
const long long A = 100000000000000LL, N = 228228;
vector<long long> t;
long long l, r, i, j, n, m, a[N], ot, o = -A;
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%lld", &a[i]);
  for (l = 0; l < n; l++)
    for (r = l + 1; r < n; r++)
      if (a[l] == a[r]) {
        ot = a[l] * 2;
        for (i = l + 1; i < r; i++)
          if (a[i] > 0) ot += a[i];
        if (ot > o) {
          t.resize(0), o = ot;
          for (i = 0; i < n; i++)
            if (i < l || i > r || (i != l && i != r && a[i] < 0))
              t.push_back(i + 1);
        }
      }
  cout << o << " " << t.size() << "\n";
  for (i = 0; i < t.size(); i++) cout << t[i] << " ";
}
