#include <bits/stdc++.h>
using namespace std;
const long long inf = 1LL << 60;
const int maxn = 300000 + 5;
int n;
int a[maxn];
long long sum[maxn];
vector<int> v;
map<int, int> l, r;
map<int, int>::iterator it;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  sum[0] = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum[i] = sum[i - 1] + (a[i] > 0 ? a[i] : 0);
    if (!l.count(a[i])) l[a[i]] = i;
    r[a[i]] = i;
  }
  int lll, rrr;
  long long res = -inf;
  for (it = l.begin(); it != l.end(); ++it) {
    int ll = it->second, rr = r[it->first];
    if (ll == rr) continue;
    long long tmp = sum[rr] - sum[ll - 1];
    if (it->first >= 0 && tmp > res) {
      res = tmp;
      lll = ll;
      rrr = rr;
    }
    if (it->first < 0 && tmp + it->first * 2 > res) {
      res = tmp + it->first * 2;
      lll = ll;
      rrr = rr;
    }
  }
  for (int i = lll + 1; i < rrr; ++i)
    if (a[i] < 0) v.push_back(i);
  sort(v.begin(), v.end());
  cout << res << " " << lll - 1 + v.size() + n - rrr << endl;
  for (int i = 1; i < lll; ++i) cout << i << " ";
  for (int i = 0; i < v.size(); ++i) cout << v[i] << " ";
  for (int i = rrr + 1; i <= n; ++i) cout << i << " ";
  cout << endl;
  return 0;
}
