#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, b;
  cin >> n;
  map<int, vector<int>> a;
  vector<long long> sum(n + 1);
  vector<long long> was(n + 1);
  sum[0] = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> b;
    was[i] = b;
    if (b > 0)
      sum[i] = sum[i - 1] + b;
    else
      sum[i] = sum[i - 1];
    a[b].push_back(i);
  }
  vector<long long> ans(3);
  ans[0] = -4000000000;
  long long now;
  for (auto c : a) {
    if (c.second.size() > 1) {
      sort(c.second.begin(), c.second.end());
      now = sum[c.second[c.second.size() - 1] - 1] - sum[c.second[0]];
      now += c.first;
      now += c.first;
      if (now > ans[0]) {
        ans[0] = now;
        ans[1] = c.second[0];
        ans[2] = c.second[c.second.size() - 1];
      }
    }
  }
  vector<long long> cut;
  for (long long i = ans[1] + 1; i < ans[2]; ++i) {
    if (was[i] < 0) cut.push_back(i);
  }
  cout << ans[0] << " " << ans[1] - 1 + cut.size() + (n - ans[2]) << endl;
  for (int i = 1; i < ans[1]; ++i) cout << i << " ";
  for (int i = 0; i < cut.size(); ++i) cout << cut[i] << " ";
  for (int i = ans[2] + 1; i <= n; ++i) cout << i << endl;
  return 0;
}
