#include <bits/stdc++.h>
using namespace std;
const int MX = 100005;
int a[MX];
long long s[MX];
int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  for (int i = (1), _b = (n + 1); i < (_b); ++i) cin >> a[i];
  for (int i = (1), _b = (n + 1); i < (_b); ++i)
    if (a[i] > 0)
      s[i] = s[i - 1] + a[i];
    else
      s[i] = s[i - 1];
  map<int, int> M;
  long long ans = -(1LL << 60);
  int l = 0, r = 0;
  for (int i = (1), _b = (n + 1); i < (_b); ++i) {
    if (M.count(a[i])) {
      long long x = s[i - 1] - s[M[a[i]]] + 2 * a[i];
      if (x > ans) {
        ans = x;
        l = M[a[i]];
        r = i;
      }
    } else
      M[a[i]] = i;
  }
  int k = 0;
  for (int i = (1), _b = (n + 1); i < (_b); ++i) {
    if (i < l || i > r)
      ++k;
    else if (a[i] < 0 && i > l && i < r)
      ++k;
  }
  cout << ans << " " << k << endl;
  if (!k) return 0;
  for (int i = (1), _b = (n + 1); i < (_b); ++i) {
    if (i < l || i > r)
      cout << i << " ";
    else if (a[i] < 0 && i > l && i < r)
      cout << i << " ";
  }
  cout << endl;
  return 0;
}
