#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long a[333333], sum[333333];
int pre[333333];
map<long long, long long> last;
bool can[333333];
long long getsum(int l, int r) {
  if (l > r) return 0;
  return sum[r] - sum[l - 1];
}
long long ans, ansl, ansr;
int main() {
  ans = -0XFFFFFFFFFFFFFFFll;
  memset(pre, -1, sizeof pre);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1];
    if (a[i] > 0) sum[i] += a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (last.find(a[i]) == last.end()) {
      last[a[i]] = i;
    } else {
      int l = last[a[i]];
      int r = i;
      if (a[i] * 2 + getsum(l + 1, r - 1) > ans) {
        ans = a[i] * 2 + getsum(l + 1, r - 1);
        ansl = l;
        ansr = r;
      }
    }
  }
  int cnt = ansl - 1 + n - ansr;
  for (int i = ansl + 1; i < ansr; i++)
    if (a[i] < 0) cnt++;
  cout << ans << " " << cnt << endl;
  for (int i = 1; i < ansl; i++) cout << i << " ";
  for (int i = ansl + 1; i < ansr; i++)
    if (a[i] < 0) cout << i << " ";
  for (int i = ansr + 1; i <= n; i++) cout << i << " ";
  return 0;
}
