#include <bits/stdc++.h>
using namespace std;
string alpha = "abcdefghijklmnopqrstuvwxyz";
long long int a[301010];
long long int prf[301010];
unordered_map<long long int, int> first;
unordered_map<long long int, int> last;
set<long long int> S;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (register int i = (1); i < (n + 1); i++) cin >> a[i];
  prf[1] = a[1];
  for (register int i = (2); i < (n + 1); i++) {
    prf[i] = prf[i - 1] + max(0ll, a[i]);
  }
  for (register int i = (1); i < (n + 1); i++) {
    if (first.count(a[i]) == 0) {
      first[a[i]] = i;
    }
    last[a[i]] = i;
    S.insert(a[i]);
  }
  int start, end;
  long long int res = -1e18;
  for (auto x : S) {
    if (first[x] == last[x]) continue;
    int i = first[x];
    int j = last[x];
    long long int _res = prf[j - 1] - prf[i] + a[i] + a[j];
    if (_res > res) {
      res = _res;
      start = i;
      end = j;
    }
  }
  cout << res << " ";
  vector<int> tree;
  int k = n - (end - start + 1);
  for (register int i = (start + 1); i < (end); i++) {
    if (a[i] < 0) {
      k++;
      tree.push_back(i);
    }
  }
  for (register int i = (1); i < (start); i++) {
    tree.push_back(i);
  }
  for (register int i = (end + 1); i < (n + 1); i++) {
    tree.push_back(i);
  }
  cout << k << "\n";
  assert(tree.size() == k);
  sort(tree.begin(), tree.end());
  for (auto i : tree) cout << i << " ";
  return 0;
}
