#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    vector<long long> a(n + 1);
    map<long long, int> loc;
    for (int i = (1); i <= ((n)); ++i) {
      cin >> a[i];
      loc[a[i]] = i;
    }
    vector<long long> b(a), bs(n + 1);
    for (int i = (1); i <= ((n)); ++i) {
      if (b[i] < 0) {
        b[i] = 0;
      }
      bs[i] = bs[i - 1] + b[i];
    }
    long long msum = -1000000000000000000LL, beg = -1, fin = -1;
    for (int i = (1); i <= ((n)); ++i) {
      if (loc.find(a[i]) == loc.end() or loc[a[i]] <= i) continue;
      int lpos = loc[a[i]];
      long long sum = bs[lpos] - bs[i - 1];
      if (a[i] != b[i]) sum += 2 * a[i];
      if (sum > msum) {
        msum = sum;
        beg = i;
        fin = loc[a[i]];
      }
      loc.erase(a[i]);
    }
    vector<int> kk;
    for (int i = (1); i <= (beg - 1); ++i) {
      kk.push_back(i);
    }
    for (int i = (beg + 1); i <= (fin - 1); ++i) {
      if (a[i] != b[i]) {
        kk.push_back(i);
      }
    }
    for (int i = (fin + 1); i <= (n); ++i) {
      kk.push_back(i);
    }
    cout << msum << ' ' << ((int)(kk).size()) << endl;
    for (int i = (0); i <= ((((int)(kk).size())) - 1); ++i) {
      cout << kk[i] << ' ';
    }
    cout << endl;
  }
  return 0;
}
