#include <bits/stdc++.h>
using namespace std;
int n;
int a[1000000];
long long sum[1000000];
map<int, int> ml, mr;
int main() {
  cin >> n;
  int ll, rr;
  vector<int> an;
  long long ma = 0;
  for (int(i) = (1); i <= (n); ++(i)) {
    scanf("%d", &a[i]);
    if (ml.find(a[i]) == ml.end()) ml[a[i]] = i;
    mr[a[i]] = i;
    sum[i] = sum[i - 1];
    if (a[i] > 0) sum[i] += a[i];
  }
  long long MAX = -1000000000 * 1LL * 1000000000;
  int l = 0, r = 0;
  for (map<int, int>::iterator il = ml.begin(), ir = mr.begin();
       il != ml.end() && ir != mr.end(); il++, ir++)
    if (il->second != ir->second) {
      if (sum[ir->second - 1] - sum[il->second] + il->first * 2 > MAX) {
        MAX = sum[ir->second - 1] - sum[il->second] + il->first * 2;
        l = il->second;
        r = ir->second;
      }
    }
  int k = l + n - r - 1;
  vector<int> out;
  for (int(i) = (l + 1); i < (r); ++(i))
    if (a[i] < 0) out.push_back(i);
  cout << MAX << ' ' << k + out.size() << '\n';
  for (int(i) = (1); i < (l); ++(i)) cout << i << ' ';
  for (int(i) = (0); i < (out.size()); ++(i)) cout << out[i] << ' ';
  for (int(i) = (r + 1); i <= (n); ++(i)) cout << i << ' ';
  return 0;
}
