#include <bits/stdc++.h>
using namespace std;
int a, b, i, j, k, n, m, cnt, le, r;
long long t[300050];
bool l[300050];
long long ans, tmp, tsum;
long long s[300050];
map<int, int> mpo;
map<int, int> mpt;
int main() {
  scanf("%d", &n);
  tsum = 0;
  s[0] = 0;
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &t[i]);
    if (mpo[t[i]] == 0)
      mpo[t[i]] = i;
    else
      mpt[t[i]] = max(mpt[t[i]], i);
    if (t[i] > 0)
      s[i] = t[i] + s[i - 1];
    else
      s[i] = s[i - 1];
    tsum += t[i];
  }
  ans = -(long long)1000000000 * 1000000;
  tmp = tsum;
  cnt = 0;
  memset(l, 0, sizeof(l));
  for (i = 1; i <= n; i++) {
    a = mpo[t[i]];
    b = mpt[t[i]];
    if (a == i && b != 0) {
      tmp = s[b - 1] - s[a] + t[i] * 2;
      if (tmp > ans) {
        ans = tmp;
        le = a;
        r = b;
      }
    }
  }
  cout << ans << " ";
  cnt = 0;
  for (i = le + 1; i < r; i++)
    if (t[i] < 0) l[i] = 1;
  for (i = le + 1; i <= r - 1; i++) {
    if (l[i]) cnt++;
  }
  printf("%d\n", le - 1 + n - r + cnt);
  for (i = 1; i < le; i++) {
    l[i] = 1;
  }
  for (i = r + 1; i <= n; i++) {
    l[i] = 1;
  }
  for (i = 1; i <= n; i++) {
    if (l[i]) printf("%d ", i);
  }
  printf("\n");
  return 0;
}
