#include <bits/stdc++.h>
using namespace std;
vector<long long> tree;
map<long long, tuple<long long, long long>> mem;
long long N = 1;
long long sum(long long l, long long r) {
  l += N;
  r += N;
  long long s = 0;
  while (l < r) {
    if (l % 2 == 1) {
      s += tree[l];
      l++;
    }
    if (r % 2 == 0) {
      s += tree[r];
      r--;
    }
    l /= 2;
    r /= 2;
  }
  if (l == r) s += tree[l];
  return s;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  while (N < n) N <<= 1;
  tree.resize(2 * N);
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > 0) tree[i + N] = a[i];
    if (mem.find(a[i]) != mem.end()) {
      get<1>(mem[a[i]]) = i;
    } else {
      mem[a[i]] = make_tuple(i, i);
    }
  }
  for (long long i = N - 1; i > 0; i--) {
    tree[i] = tree[2 * i] + tree[2 * i + 1];
  }
  long long ans = -999999999999999, ll, rr;
  for (auto [x, y] : mem) {
    auto [l, r] = y;
    if (l == r) continue;
    if (2 * x + sum(l + 1, r - 1) > ans) {
      ans = 2 * x + sum(l + 1, r - 1);
      ll = l;
      rr = r;
    }
  }
  vector<long long> treecut;
  for (long long i = 0; i < ll; i++) treecut.push_back(i);
  for (long long i = ll + 1; i < rr; i++) {
    if (a[i] < 0) treecut.push_back(i);
  }
  for (long long i = rr + 1; i < n; i++) treecut.push_back(i);
  cout << ans << " " << treecut.size() << "\n";
  for (long long i : treecut) cout << i + 1 << " ";
  cout << "\n";
}
