#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long i, j, k, l, m, n, t, sum = 0;
  cin >> n;
  vector<long long> ar(n + 1);
  vector<long long> arr(n + 1);
  vector<long long> pre(n + 1);
  map<long long, vector<long long>> m1;
  for (i = 1; i <= n; i++) {
    cin >> ar[i];
    m1[ar[i]].push_back(i);
    arr[i] = ar[i];
  }
  for (i = 1; i <= n; i++) {
    if (arr[i] < 0) arr[i] = 0;
  }
  long long c = 0;
  pre[0] = 0;
  for (i = 1; i <= n; i++) {
    pre[i] = arr[i] + pre[i - 1];
  }
  sum = 0;
  long long min1 = INT_MIN;
  long long idx1, idx2;
  sum = 0;
  for (auto it = m1.begin(); it != m1.end(); it++) {
    if (it->second.size() > 1) {
      auto a = it->second.begin();
      auto b = it->second.end() - 1;
      if ((pre[*b] - pre[*a] + arr[*a]) > min1) {
        min1 = pre[*b] - pre[*a] + ar[*a];
        if (ar[*b] < 0) min1 = min1 + ar[*b];
        idx1 = *a;
        idx2 = *b;
      }
    }
  }
  cout << min1 << " ";
  long long ans = 0;
  ans = idx1 - 1 + n - idx2;
  for (i = idx1 + 1; i < idx2; i++)
    if (ar[i] < 0) ans = ans + 1;
  cout << ans << endl;
  vector<long long> res;
  for (i = 1; i < idx1; i++) {
    res.push_back(i);
  }
  for (i = idx1 + 1; i < idx2; i++)
    if (ar[i] < 0) res.push_back(i);
  for (i = idx2 + 1; i <= n; i++) res.push_back(i);
  for (i = 0; i < res.size(); i++) cout << res[i] << " ";
}
