#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005;
int n;
long long a[MAXN];
long long sum[MAXN] = {};
map<long long, int> frst;
long long query(int x, int y) {
  if (y <= x + 1) return 0LL;
  return sum[y - 1] - sum[x];
}
int main() {
  scanf("%d", &(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];
  }
  long long curr_max = -(1LL << 62);
  int loc = -1;
  for (int i = 1; i <= n; i++) {
    if (frst.find(a[i]) == frst.end()) {
      frst[a[i]] = i;
    } else {
      int st = frst[a[i]];
      int ed = i;
      long long val = query(st, ed) + 2 * a[i];
      if (val > curr_max) {
        curr_max = val;
        loc = i;
      }
    }
  }
  int st = frst[a[loc]];
  int ed = loc;
  vector<int> del_list;
  for (int i = 1; i < st; i++) {
    del_list.push_back(i);
  }
  for (int i = st + 1; i <= ed - 1; i++) {
    if (a[i] <= 0LL) del_list.push_back(i);
  }
  for (int i = ed + 1; i <= n; i++) {
    del_list.push_back(i);
  }
  cout << curr_max << " " << ((int)(del_list).size()) << endl;
  for (int i = 0; i < ((int)(del_list).size()); i++) {
    cout << del_list[i] << (i < ((int)(del_list).size()) - 1 ? " " : "\n");
  }
  cout << flush;
  return 0;
}
