#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cout.tie(0);
  long long n, a[300001], s[300001], i, minimo, massimo, seq, tot,
      indmin = 0, indmax = 0, solmin = 0, solmax;
  long long ans = -1e18;
  vector<tuple<long long, long long, long long>> v;
  vector<long long> z;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0) {
      if (a[i] < 0)
        s[0] = 0;
      else
        s[0] = a[0];
    } else {
      if (a[i] < 0)
        s[i] = s[i - 1];
      else
        s[i] = s[i - 1] + a[i];
    }
  }
  if (n == 2) {
    cout << a[0] + a[1] << " 0";
    return 0;
  }
  for (int i = 0; i < n; i++) v.push_back(make_tuple(a[i], s[i], i));
  sort(v.begin(), v.end());
  minimo = get<1>(v[0]);
  massimo = get<1>(v[0]);
  seq = 0;
  for (int i = 1; i < n; i++) {
    if (get<0>(v[i - 1]) == get<0>(v[i])) {
      if (massimo <= get<1>(v[i])) {
        massimo = get<1>(v[i]);
        indmax = get<2>(v[i]);
      } else if (minimo > get<1>(v[i])) {
        minimo = get<1>(v[i]);
        indmin = get<2>(v[i]);
      }
      seq++;
    } else {
      if (seq > 0) {
        if (get<0>(v[i - 1]) <= 0)
          tot = massimo - minimo + 2 * get<0>(v[i - 1]);
        else
          tot = massimo - minimo + get<0>(v[i - 1]);
        if (tot >= ans) {
          ans = tot;
          solmin = indmin;
          solmax = indmax;
        }
      }
      minimo = get<1>(v[i]);
      massimo = get<1>(v[i]);
      indmin = get<2>(v[i]);
      indmax = get<2>(v[i]);
      seq = 0;
    }
  }
  if (seq > 0) {
    if (get<0>(v[n - 1]) <= 0)
      tot = massimo - minimo + 2 * get<0>(v[n - 1]);
    else
      tot = massimo - minimo + get<0>(v[n - 1]);
    if (tot >= ans) {
      ans = tot;
      solmin = indmin;
      solmax = indmax;
    }
  }
  for (int i = 0; i < solmin; i++) z.push_back(i + 1);
  for (int i = solmin + 1; i < solmax; i++)
    if (a[i] < 0) z.push_back(i + 1);
  for (int i = solmax + 1; i < n; i++) z.push_back(i + 1);
  cout << ans << " " << z.size() << endl;
  for (int i = 0; i < z.size(); i++) cout << z[i] << " ";
  return 0;
}
