#include <bits/stdc++.h>
using namespace std;
int n;
long long x[300001];
long long sum[300001];
map<int, int> lastPos;
int ansL, ansR;
long long ans = -1000000000000000LL;
int MAIN() {
  cin >> n;
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
    sum[i] = sum[i - 1] + max(0LL, x[i]);
  }
  for (int i = n; i >= 1; i--) {
    if (lastPos.count(x[i])) {
      int R = lastPos[x[i]];
      long long thisSol = 2 * x[i] + sum[R - 1] - sum[i];
      if (thisSol > ans) {
        ans = thisSol;
        ansL = i;
        ansR = R;
      }
    } else
      lastPos[x[i]] = i;
  }
  cout << ans << " ";
  vector<int> cuts;
  for (int i = 1; i < ansL; i++) cuts.push_back(i);
  for (int i = ansL + 1; i < ansR; i++)
    if (x[i] < 0) cuts.push_back(i);
  for (int i = ansR + 1; i <= n; i++) cuts.push_back(i);
  cout << cuts.size() << endl;
  for (int i = 0; i < cuts.size(); i++) {
    cout << cuts[i];
    if (i == cuts.size() - 1)
      cout << endl;
    else
      cout << " ";
  }
  return 0;
}
int main() {
  ios ::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  return MAIN();
}
