#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T abs(T x) {
  return x < 0 ? -x : x;
}
const int MAXN = 310000;
int a[MAXN], ind[MAXN], ind_cut[MAXN];
long long sum[MAXN];
bool comp(int ind1, int ind2) {
  return ((a[ind1] < a[ind2]) || (a[ind1] == a[ind2] && ind1 < ind2));
}
int main() {
  int n;
  cin >> n;
  sum[0] = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    sum[i + 1] = (a[i] > 0 ? sum[i] + a[i] : sum[i]);
    ind[i] = i;
  }
  sort(ind, ind + n, comp);
  int i = 0;
  int ind_l, ind_r;
  long long max_sum = -2 * inf;
  ind[n] = n;
  a[n] = inf;
  while (i < n) {
    int j = i;
    while (a[ind[j + 1]] == a[ind[i]]) j++;
    long long temp = sum[ind[j]] - sum[ind[i] + 1] + 2 * a[ind[i]];
    if (j > i && temp > max_sum) {
      max_sum = temp;
      ind_l = ind[i];
      ind_r = ind[j];
    }
    i = j + 1;
  }
  int num = 0;
  for (int i = 0; i < ind_l; ++i) {
    ind_cut[num] = i + 1;
    num++;
  }
  for (int i = ind_l + 1; i < ind_r; ++i) {
    if (a[i] < 0) {
      ind_cut[num] = i + 1;
      num++;
    }
  }
  for (int i = ind_r + 1; i < n; ++i) {
    ind_cut[num] = i + 1;
    num++;
  }
  cout << max_sum << " " << num << endl;
  for (int i = 0; i < num; ++i) {
    cout << ind_cut[i] << " ";
  }
  cout << endl;
  return 0;
}
