#include <bits/stdc++.h>
using namespace std;
int a[300001], d[300001];
long long b[300001], c[300001];
map<int, int> mp;
int main() {
  int n, i, l, r, j, k;
  long long s, _s;
  for (scanf("%d", &n), i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[i] = b[i - 1] + a[i];
    c[i] = c[i - 1] + (a[i] > 0 ? a[i] : 0);
    d[i] = d[i - 1] + (a[i] < 0);
    if (!mp.count(a[i])) mp[a[i]] = i;
  }
  for (i = n, s = 1ll << 63; i; i--) {
    j = mp[a[i]];
    if (i == j) continue;
    _s = c[i] - c[j - 1];
    if (a[i] < 0) _s += 2 * a[i];
    if (_s > s) {
      s = _s;
      l = j;
      r = i;
    }
  }
  printf("%I64d %d\n", s, d[r - 1] - d[l] + l - 1 + n - r);
  for (i = 1; i < l; i++) printf("%d ", i);
  for (i = l + 1; i < r; i++) {
    if (a[i] < 0) printf("%d ", i);
  }
  for (i = r + 1; i <= n; i++) printf("%d ", i);
  puts("");
  return 0;
}
