#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int d[N];
int n;
long long sum[N];
int del[N];
map<int, pair<int, int> > mp;
map<int, pair<int, int> >::iterator it;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> d[i];
  for (int i = 0; i < n; ++i) {
    it = mp.find(d[i]);
    if (it == mp.end()) {
      mp[d[i]] = make_pair((i), (i));
    } else if (it->second.second < i)
      it->second.second = i;
    if (d[i] > 0)
      sum[i] += (i ? sum[i - 1] : 0) + d[i];
    else {
      sum[i] = (i ? sum[i - 1] : 0);
    }
  }
  long long ans = -1LL << 62;
  pair<int, int> ind;
  for (it = mp.begin(); it != mp.end(); ++it) {
    pair<int, int> pr = it->second;
    if (pr.first == pr.second) continue;
    long long t0 = pr.first ? sum[pr.first - 1] : 0;
    long long t = sum[pr.second] - t0;
    if (d[pr.second] <= 0) {
      t += 2LL * d[pr.second];
    }
    if (ans < t) {
      ans = t;
      ind = pr;
    }
  }
  int cnt = 0;
  int i = 0;
  while (i < ind.first) del[cnt++] = i++;
  i++;
  while (i < ind.second) {
    if (d[i] <= 0) del[cnt++] = i;
    i++;
  }
  i++;
  while (i < n) del[cnt++] = i++;
  cout << ans << " " << cnt << endl;
  for (int i = 0; i < cnt; ++i) {
    if (i) putchar(' ');
    printf("%d", del[i] + 1);
  }
  puts("");
  return 0;
}
