#include <bits/stdc++.h>
using namespace std;
long long sumneg[1000000];
long long nega(int a, int b) {
  b--;
  a++;
  if (b < a) {
    return 0;
  } else
    return sumneg[b] - sumneg[a - 1];
}
int main() {
  int n;
  cin >> n;
  long long t[n];
  map<long long, int> mp;
  long long keep = -1;
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  vector<long long> nopes;
  long long sum[n + 1];
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + t[i];
    sumneg[i + 1] = sumneg[i];
    if (t[i] < 0) sumneg[i + 1] += t[i];
  }
  map<long long, pair<int, int>> interv;
  for (int i = 0; i < n; i++) {
    if (interv[t[i]].first == 0) {
      interv[t[i]].first = i + 1;
    } else {
      interv[t[i]].second = i + 1;
    }
  }
  long long mx = -10000000000000000;
  int aa, bb;
  for (auto it = interv.begin(); it != interv.end(); it++) {
    if ((it->second.second * it->second.first != 0) &&
        mx < (-(nega(it->second.first, it->second.second)) +
              sum[it->second.second] - sum[it->second.first - 1])) {
      mx = -nega(it->second.first, it->second.second) + sum[it->second.second] -
           sum[it->second.first - 1];
      aa = it->second.first;
      bb = it->second.second;
    }
  }
  map<int, int> nn;
  nn[aa - 1]++;
  nn[bb - 1]++;
  for (int i = aa + 1; i < bb; i++) {
    if (t[i - 1] >= 0) nn[i - 1]++;
  }
  int y = 0;
  for (int i = 0; i < n; i++) {
    if (nn[i] == 0) {
      y++;
    }
  }
  cout << mx << " " << y << endl;
  for (int i = 0; i < n; i++) {
    if (nn[i] == 0) {
      cout << i + 1 << " ";
    }
  }
}
