#include <bits/stdc++.h>
using namespace std;
const int MaxN = 200005;
const double eps = 1e-7;
const double DINF = 1e100;
const int INF = 1000000006;
const long long LINF = 1000000000000000005ll;
int n;
int a[MaxN];
long long sum[MaxN];
map<int, int> MAP;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    if (a[i] >= 0)
      sum[i] = sum[i - 1] + a[i];
    else
      sum[i] = sum[i - 1];
    if (!MAP.count(a[i])) MAP[a[i]] = i;
  }
  long long ans = -LINF;
  int l = -1, r = -1;
  for (int i = n; i >= 1; --i) {
    if (!MAP.count(a[i])) continue;
    int tl = MAP[a[i]], tr = i;
    if (tl == tr) continue;
    long long tsum = sum[tr - 1] - sum[tl] + 2 * a[tl];
    if (tsum > ans) {
      ans = tsum;
      l = tl;
      r = tr;
    }
  }
  vector<int> res;
  for (int i = l + 1; i < r; ++i)
    if (a[i] < 0) res.push_back(i);
  for (int i = 1; i < l; ++i) res.push_back(i);
  for (int i = r + 1; i <= n; ++i) res.push_back(i);
  cout << ans << " " << res.size() << endl;
  for (int i = 0; i < (int)res.size(); ++i) printf("%d ", res[i]);
  return 0;
}
