#include <bits/stdc++.h>
using namespace std;
long long n, a[300005], b[300005] = {}, res = -100000000000000LL;
map<long long, long long> m;
vector<int> cut;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = b[i - 1] + max(a[i], 0LL);
    if (m[a[i]] > 0)
      res = max(res, b[i] - b[m[a[i]] - 1] + (a[i] < 0) * 2 * a[i]);
    else
      m[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (i > m[a[i]] && res == b[i] - b[m[a[i]] - 1] + (a[i] < 0) * 2 * a[i]) {
      for (int j = 1; j < m[a[i]]; j++) cut.push_back(j);
      for (int j = m[a[i]] + 1; j < i; j++)
        if (a[j] < 0) cut.push_back(j);
      for (int j = i + 1; j <= n; j++) cut.push_back(j);
      break;
    }
  }
  cout << res << " " << cut.size() << endl;
  for (int i = 0; i < cut.size(); i++) cout << cut[i] << " ";
  cout << endl;
}
