#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  ;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  ;
  vector<long long> dp(n + 1, 0);
  map<int, pair<int, int>> m;
  for (int i = 0; i < n; i++) {
    dp[i + 1] = dp[i] + (a[i] < 0 ? 0 : a[i]);
    if (m.find(a[i]) == m.end()) {
      m[a[i]] = make_pair(i, i);
    } else {
      m[a[i]].second = i;
    }
  }
  long long sum = LONG_LONG_MIN;
  int l = 0;
  int r = 0;
  for (auto it = m.rbegin(); it != m.rend(); it++) {
    auto range = it->second;
    if (range.first != range.second) {
      long long curr = dp[range.second] - dp[range.first + 1] + (2 * it->first);
      if (curr > sum) {
        sum = curr;
        l = range.first;
        r = range.second;
      }
    }
  }
  vector<int> removes;
  for (int i = 0; i < l; i++) {
    removes.push_back(i + 1);
  }
  for (int i = l + 1; i < r; i++) {
    if (a[i] < 0) {
      removes.push_back(i + 1);
    }
  }
  for (int i = r + 1; i < n; i++) {
    removes.push_back(i + 1);
  }
  cout << sum << ' ' << removes.size() << '\n';
  for (auto x : removes) {
    cout << to_string(x) << ' ';
  };
  cout << '\n';
  ;
  return 0;
}
