#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long arr[300006], mx = LONG_LONG_MIN;
  bool yes[300005];
  memset(yes, 0, sizeof yes);
  arr[0] = 0;
  map<long long, int> in;
  int s, e;
  for (int i = 0; i < N; i++) {
    long long a;
    scanf("%I64d", &a);
    if (a > 0)
      arr[i] = a + arr[i - 1];
    else
      arr[i] = arr[i - 1], yes[i] = 1;
    if (in.find(a) == in.end())
      in[a] = i;
    else {
      long long res = arr[i] - arr[in[a] - 1];
      if (a < 0) res += (a * 2);
      if (mx < res) {
        mx = res, s = in[a], e = i;
      }
    }
  }
  vector<int> v;
  for (int i = 0; i < N; i++)
    if (i < s || i > e || (i > s && i < e && yes[i])) v.push_back(i + 1);
  printf("%I64d %d\n", mx, v.size());
  for (int i = 0; i < v.size(); i++)
    if (i)
      printf(" %d", v[i]);
    else
      printf("%d", v[i]);
}
