#include <bits/stdc++.h>
using namespace std;
struct node {
  long long num;
  int pos;
};
bool comp(node a, node b) {
  if (a.num == b.num) {
    return a.pos < b.pos;
  } else {
    return a.num < b.num;
  }
}
long long arr[1000005], sum[1000005];
node z[1000005];
int main() {
  int i, j, tst, cas = 1, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%I64d", &arr[i]);
    z[i].num = arr[i];
    z[i].pos = i;
  }
  memset(sum, 0, sizeof(sum));
  if (arr[0] > 0) {
    sum[0] = arr[0];
  }
  for (i = 1; i < n; i++) {
    if (arr[i] > 0) {
      sum[i] = arr[i];
    }
    sum[i] += sum[i - 1];
  }
  sort(z, z + n, comp);
  long long buff = -999999999999999999, pres;
  int strt, end;
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (z[i].num != z[j].num) {
        break;
      }
      pres = sum[z[j].pos - 1] - sum[z[i].pos] + arr[z[i].pos] + arr[z[j].pos];
      if (pres > buff) {
        buff = pres;
        strt = z[i].pos;
        end = z[j].pos;
      }
    }
  }
  int cnt = 0;
  vector<int> myv;
  for (i = 0; i < strt; i++) {
    myv.push_back(i + 1);
  }
  for (i = strt + 1; i < end; i++) {
    if (arr[i] < 0) {
      cnt++;
      myv.push_back(i + 1);
    }
  }
  cnt += strt;
  cnt += (n - end - 1);
  for (i = end + 1; i < n; i++) {
    myv.push_back(i + 1);
  }
  printf("%I64d %d\n", buff, cnt);
  if (cnt > 0) {
    cout << myv[0];
    for (i = 1; i < myv.size(); i++) {
      printf(" %d", myv[i]);
    }
  }
  putchar(10);
  return 0;
}
