#include <bits/stdc++.h>
using namespace std;
template <class T>
void setmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
void setmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
const int MAXN = 300010;
int a[MAXN];
long long s[MAXN];
int n;
map<int, int> h;
int main() {
  scanf("%d", &n);
  long long ans = -(long long)(1 << 30) * (long long)(1 << 20);
  int ansl, ansr;
  s[0] = 0;
  for (int i = (int)(1); i <= (int)(n); ++i) {
    scanf("%d", &a[i]);
    s[i] = s[i - 1];
    if (a[i] > 0) s[i] += a[i];
    if (h.find(a[i]) == h.end()) {
      h[a[i]] = i;
    } else {
      int j = h[a[i]];
      long long t = s[i - 1] - s[j] + a[j];
      if (t + a[i] > ans) {
        ans = t + a[i];
        ansl = j;
        ansr = i;
      }
      if (t < 0) h[a[i]] = i;
    }
  }
  vector<int> rem;
  for (int i = (int)(1); i <= (int)(n); ++i) {
    if (i < ansl || i > ansr)
      rem.push_back(i);
    else if (i > ansl && i < ansr && a[i] < 0)
      rem.push_back(i);
  }
  cout << ans << " " << rem.size() << endl;
  for (int i = 0; i < (int)(rem.size()); ++i)
    printf("%d%c", rem[i], i < (int)rem.size() - 1 ? ' ' : '\n');
  return 0;
}
