#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const double PI = acos(-1);
map<long long, long long> M;
int main() {
  int n;
  cin >> n;
  long long s = -INF * INF, ss = 0;
  int p = 0, p2 = 0;
  vector<long long> a;
  vector<long long> c;
  for (int i = 0; i < n; i++) {
    long long k;
    cin >> k;
    a.push_back(k);
    if (k > 0) ss += k;
    c.push_back(ss);
    if (!M[k])
      M[k] = i + 1;
    else {
      long long t = 0;
      if (M[k] == 1)
        t = c[i];
      else
        t = c[i] - c[M[k] - 2];
      if (k < 0) t += 2 * k;
      if (t > s) {
        s = t;
        p = i;
        p2 = M[k] - 1;
      }
    }
  }
  vector<long long> b;
  for (int i = 0; i < n; i++) {
    if (i < p2 || i > p) {
      b.push_back(i + 1);
    } else if ((i != p2 && i != p) && a[i] < 0)
      b.push_back(i + 1);
  }
  cout << s << " " << b.size() << endl;
  for (int i = 0; i < b.size(); i++) cout << b[i] << " ";
}
