#include <bits/stdc++.h>
using namespace std;
map<int, int> Fuck;
int n, cnt, l[400100], r[400100], num[400100];
long long sum[400100], sumng[400100];
int main() {
  Fuck.clear();
  cin >> n;
  cnt = 0;
  int i;
  sum[0] = 0;
  sumng[0] = 0;
  for (i = 1; i <= n; i++) {
    int x;
    cin >> x;
    num[i] = x;
    if (Fuck[x] == 0) {
      Fuck[x] = ++cnt;
      l[cnt] = i;
      r[cnt] = i;
    }
    if (i > r[Fuck[x]]) r[Fuck[x]] = i;
    sum[i] = sum[i - 1] + x;
    if (x < 0)
      sumng[i] = sumng[i - 1] + x;
    else
      sumng[i] = sumng[i - 1];
  }
  long long ans = -1000000000000000;
  int L, R;
  for (i = 1; i <= n; i++) {
    int p = Fuck[num[i]];
    if (l[p] != r[p]) {
      long long tmp =
          sum[r[p]] - sum[l[p] - 1] - (sumng[r[p] - 1] - sumng[l[p]]);
      if (tmp > ans) ans = tmp, L = l[p], R = r[p];
    }
  }
  int cal = 0;
  cal = n - (R - L + 1);
  for (i = L + 1; i < R; i++)
    if (num[i] < 0) cal++;
  cout << ans << " " << cal << endl;
  bool flag = true;
  for (i = 1; i < L; i++)
    if (flag) {
      flag = false;
      cout << i;
    } else
      cout << " " << i;
  for (i = L + 1; i < R; i++)
    if (num[i] < 0) {
      if (flag) {
        flag = false;
        cout << i;
      } else
        cout << " " << i;
    }
  for (i = R + 1; i <= n; i++)
    if (flag) {
      flag = false;
      cout << i;
    } else
      cout << " " << i;
  cout << endl;
}
