#include <bits/stdc++.h>
using namespace std;
map<int, int> fi;
map<int, int> la;
int a[100100];
long long sum[100100];
vector<int> b;
int main() {
  int n;
  cin >> n;
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  for (int i = (0); i < (n); ++i) la[a[i]] = i;
  for (int i = n - 1; i >= 0; --i) fi[a[i]] = i;
  for (int i = (0); i < (n); ++i) {
    if (a[i] < 0)
      sum[i] = 0;
    else
      sum[i] = a[i];
    if (i) sum[i] += sum[i - 1];
  }
  int bl = -1, br = -1;
  long long res = -1000000000000000000ll;
  for (auto it = fi.begin(); it != fi.end(); ++it) {
    int v = it->first;
    int l = it->second;
    int r = la[v];
    if (l != r) {
      long long now = sum[r - 1] - sum[l] + v + v;
      if (now > res) {
        res = now;
        bl = l;
        br = r;
      }
    }
  }
  for (int i = (0); i < (n); ++i)
    if ((i < bl) || (i > br) || ((i > bl) && (i < br) && (a[i] < 0)))
      b.push_back(i + 1);
  cout << res << " " << b.size() << endl;
  for (int i = (0); i < (b.size()); ++i) {
    if (i) printf(" ");
    printf("%d", b[i]);
  }
  printf("\n");
  return 0;
}
