#include <bits/stdc++.h>
using namespace std;
map<int, int> fir;
int i, j, n, m, e, ll, rr;
long long s[623123], ans, res;
int a[666666];
long long get(int l, int r) {
  if (l > r) return 0;
  if (l == 0)
    return s[r];
  else
    return s[r] - s[l - 1];
}
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  if (a[i] < 0)
    s[0] = 0;
  else
    s[0] = a[0];
  for (i = 1; i < n; ++i) {
    if (a[i] < 0)
      s[i] = s[i - 1];
    else
      s[i] = s[i - 1] + a[i];
  }
  ans = 0;
  for (i = 0; i < n; ++i) ans = ans - 1000000001;
  for (i = 0; i < n; ++i) {
    e = fir[a[i]];
    if (e != 0) {
      e--;
      res = get(e + 1, i - 1) + a[i] * 2;
      if (res > ans) {
        ans = res;
        ll = e;
        rr = i;
      }
    } else {
      fir[a[i]] = i + 1;
    }
  }
  res = 0;
  for (i = 0; i < n; ++i)
    if (i == ll || i == rr)
      continue;
    else if (i < ll || i > rr || a[i] < 0)
      ++res;
  cout << ans << " " << res << endl;
  for (i = 0; i < n; ++i)
    if (i == ll || i == rr)
      continue;
    else if (i < ll || i > rr || a[i] < 0)
      cout << i + 1 << " ";
  cout << endl;
}
