#include <bits/stdc++.h>
using namespace std;
int n, tree[300005];
long long sum[300005];
vector<pair<int, int> > vec;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> tree[i];
  sum[0] = tree[0] > 0 ? tree[0] : 0;
  for (int i = 1; i < n; i++) {
    if (tree[i] > 0)
      sum[i] = sum[i - 1] + tree[i];
    else
      sum[i] = sum[i - 1];
  }
  for (int i = 0; i < n; i++) vec.push_back(make_pair(tree[i], i));
  sort((vec).begin(), (vec).end());
  long long l, r, ans = -(1ll << 60), t;
  for (int i = 0; i < n; i++) {
    bool f = 0;
    int j;
    for (j = i + 1; j < n; j++) {
      if (vec[j].first != vec[i].first) break;
      f = 1;
    }
    j--;
    if (f) {
      t = sum[vec[j].second] - sum[vec[i].second] + vec[j].first;
      if (vec[i].first < 0) t += vec[i].first;
      if (ans < t) {
        ans = t;
        l = vec[i].second, r = vec[j].second;
      }
    }
    i = j;
  }
  int del = l;
  for (int i = l + 1; i < r; i++)
    if (tree[i] <= 0) del++;
  del += n - r - 1;
  cout << ans << ' ' << del << endl;
  for (int i = 0; i < l; i++) cout << i + 1 << ' ';
  for (int i = l + 1; i < r; i++)
    if (tree[i] <= 0) cout << i + 1 << ' ';
  for (int i = r + 1; i < n; i++) cout << i + 1 << ' ';
  return 0;
}
