#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e14 + 7;
vector<int> res, f, l;
vector<long long> v;
long long a[100100];
long long s[100100];
pair<long long, int> b[100100];
int n;
long long best;
int bf, bl;
void init(void) {
  int i;
  scanf("%d", &n);
  s[0] = 0;
  for (i = 1; i <= n; i = i + 1) {
    scanf("%I64d", &a[i]);
    if (a[i] > 0)
      s[i] = s[i - 1] + a[i];
    else
      s[i] = s[i - 1];
    b[i] = pair<long long, int>(a[i], i);
  }
  sort(&b[1], &b[n + 1]);
  b[0] = pair<long long, int>(-INF, -1);
  best = -INF;
  v.clear();
  f.clear();
  l.clear();
  for (i = 1; i <= n; i = i + 1)
    if (b[i].first > b[i - 1].first) {
      v.push_back(b[i].first);
      f.push_back(b[i].second);
      if (i > 1) l.push_back(b[i - 1].second);
    }
  l.push_back(b[n].second);
}
void count(void) {
  int i;
  for (i = 0; i < v.size(); i = i + 1)
    if (l[i] != f[i]) {
      if (best < a[f[i]] + a[l[i]] + s[l[i] - 1] - s[f[i]]) {
        best = a[f[i]] + a[l[i]] + s[l[i] - 1] - s[f[i]];
        bf = f[i];
        bl = l[i];
      }
    }
}
void print(void) {
  res.clear();
  int i;
  for (i = 1; i < bf; i = i + 1) res.push_back(i);
  for (i = bf + 1; i < bl; i = i + 1)
    if (a[i] <= 0) res.push_back(i);
  for (i = bl + 1; i <= n; i = i + 1) res.push_back(i);
  printf("%I64d %d\n", best, res.size());
  if (res.size() == 0) return;
  for (i = 0; i < res.size() - 1; i = i + 1) printf("%d ", res[i]);
  printf("%d", res[res.size() - 1]);
}
int main(void) {
  init();
  count();
  print();
  return 0;
}
