#include <bits/stdc++.h>
using namespace std;
int i, n, v[300100], st, c, j, dr, fo;
long long S[300100], best, cur, IN;
vector<int> h[666013], p[666013];
int ab(int x) {
  if (x < 0) return -x;
  return x;
};
void insert(int x) {
  int mo = ab(x) % 666013;
  h[mo].push_back(x);
  p[mo].push_back(i);
}
int find(int x) {
  int mo = ab(x) % 666013;
  for (j = 0; j < h[mo].size(); ++j)
    if (x == h[mo][j]) return p[mo][j];
  return 0;
}
int main() {
  IN = -(1 << 30);
  IN = IN * IN;
  IN = -IN;
  best = IN;
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> v[i];
    S[i] = S[i - 1];
    if (v[i] >= 0) S[i] += v[i];
    fo = find(v[i]);
    if (!fo)
      insert(v[i]);
    else {
      cur = S[i - 1] - S[fo] + 2 * v[i];
      if (cur > best) {
        best = cur;
        st = fo;
        dr = i;
      }
    }
  }
  for (i = st + 1; i < dr; ++i)
    if (v[i] < 0) c++;
  cout << best << " " << n + c - (dr - st + 1) << "\n";
  for (i = 1; i < st; ++i) cout << i << " ";
  for (i = st + 1; i < dr; ++i)
    if (v[i] < 0) cout << i << " ";
  for (i = dr + 1; i <= n; ++i) cout << i << " ";
  return 0;
}
