#include <bits/stdc++.h>
using namespace std;
int n, A[300003], i, j, x, y;
pair<int, int> B[300003];
long long res = -1e18, S[300003];
vector<int> v;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) scanf("%d", &A[i]), B[i] = make_pair(A[i], i);
  for (int i = 0; i < (n); i++) S[i + 1] = S[i] + max(0, A[i]);
  sort(B, B + n);
  while (i < n) {
    j = i;
    while (j < n && B[j].first == B[i].first) j++;
    if (j - i > 1) {
      long long s = S[B[j - 1].second] - S[B[i].second + 1] + 2ll * B[i].first;
      if (res < s) res = s, y = B[j - 1].second, x = B[i].second;
    }
    i = j;
  }
  for (int i = 0; i < (x); i++) v.push_back(i);
  for (int i = x + 1; i < y; i++)
    if (A[i] < 0) v.push_back(i);
  for (int i = y + 1; i < n; i++) v.push_back(i);
  printf("%I64d %d\n", res, v.size());
  for (int i = 0; i < (int)v.size(); i++) printf("%d ", v[i] + 1);
  printf("\n");
  return 0;
}
