#include <bits/stdc++.h>
using namespace std;
long long x[300003], y[300003];
const long long inf = 10000000000000000LL;
int n;
int main() {
  long long d;
  while (cin >> n) {
    map<long long, vector<long long> > m;
    for (int i = (int)1; i < (int)n + 1; i++) {
      cin >> d, m[d].push_back(i), y[i] = d;
      if (d < 0)
        x[i] = 0;
      else
        x[i] = d;
    }
    for (int i = (int)1; i < (int)n + 1; i++) x[i] += x[i - 1];
    long long res = -inf;
    int L = -1, R = -1;
    for (typeof(m.begin()) iter = m.begin(); iter != m.end(); iter++) {
      vector<long long> v = (iter->second);
      if (v.size() < 2) continue;
      int l = v[0], r = v.back();
      long long sum = y[l] + y[l];
      if (r - l > 1) sum += (x[r - 1] - x[l]);
      if (sum > res) res = sum, L = l, R = r;
    }
    if (L == -1) assert(0);
    vector<int> k;
    for (int i = (int)1; i < (int)n + 1; i++) {
      if (i < L || i > R)
        k.push_back(i);
      else if (y[i] < 0 && i > L && i < R)
        k.push_back(i);
    }
    cout << res << " " << k.size() << endl;
    for (int i = (int)0; i < (int)k.size(); i++) cout << k[i] << " ";
    puts("");
  }
  return 0;
}
