#include <bits/stdc++.h>
using namespace std;
int wait;
const long long INF = 10000005;
const int N = 1e5 + 5;
int MAX = 10000000;
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long ans = -(long long)1ll << 60, l_idx = 0, r_idx = 0;
  int n;
  cin >> n;
  long long arr[n];
  long long conSum[n + 1];
  conSum[0] = 0;
  map<long long, vector<long long> > make_pair;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    make_pair[arr[i]].push_back(i);
    (arr[i] >= 0) ? conSum[i + 1] = conSum[i] + arr[i]
                  : conSum[i + 1] = conSum[i];
  }
  for (auto p : make_pair) {
    long long l, r;
    if (p.second.size() >= 2) {
      l = p.second[0];
      r = p.second[p.second.size() - 1];
    } else
      continue;
    long long x = conSum[r] - conSum[l + 1] + arr[l] * 2;
    if (x >= ans)
      l_idx = l, r_idx = r, ans = conSum[r] - conSum[l + 1] + arr[l] * 2;
  }
  cout << ans << " ";
  vector<long long> cut;
  for (long long i = 0; i < n; i++)
    if (i < l_idx || i > r_idx || arr[i] < 0 && i > l_idx && i < r_idx)
      cut.push_back(i + 1);
  cout << cut.size() << endl;
  for (int i = 0; i < cut.size(); i++) cout << cut[i] << " ";
}
