#include <bits/stdc++.h>
using namespace std;
int N;
long long a[500000], b[500000], s[500000];
map<long long, int> last;
int pos;
long long best = -1000000000000;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    b[i] = max(a[i], 0LL);
    last[a[i]] = i;
  }
  partial_sum(b, b + N, s);
  for (int i = 0; i < N; i++) {
    if (last[a[i]] != i) {
      long long b = s[last[a[i]] - 1] - s[i] + 2 * a[i];
      if (b > best) {
        best = b;
        pos = i;
      }
    }
  }
  vector<int> cut;
  for (int i = 0; i < pos; i++) cut.push_back(i + 1);
  for (int i = pos + 1; i < last[a[pos]]; i++)
    if (a[i] < 0) cut.push_back(i + 1);
  for (int i = last[a[pos]] + 1; i < N; i++) cut.push_back(i + 1);
  cout << best << " " << cut.size() << "\n";
  if (cut.size() > 0) {
    cout << cut[0];
    for (int i = 1; i < cut.size(); i++) cout << " " << cut[i];
    cout << endl;
  }
  return 0;
}
