#include <bits/stdc++.h>
using namespace std;
template <class F, class S>
ostream& operator<<(ostream& o, const pair<F, S>& p) {
  return o << "(" << p.first << ", " << p.second << ")";
}
template <class C>
void O__(ostream& o, const C& c) {
  bool f = 1;
  for (const auto& x : c) {
    if (!f) o << ", ";
    f = 0;
    o << x;
  }
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  O__(o, v);
  o << "]";
  return o;
}
template <class T, class V>
ostream& operator<<(ostream& o, const map<T, V>& v) {
  o << "{";
  O__(o, v);
  o << "}";
  return o;
}
template <class T>
ostream& operator<<(ostream& o, const set<T>& v) {
  o << "{";
  O__(o, v);
  o << "}";
  return o;
}
const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-9;
const int INF = (1 << 31) - 1;
const long long LLINF = (1LL << 63) - 1;
int main() {
  int n;
  cin >> n;
  map<int, int> was;
  map<int, long long> first;
  map<int, long long> last;
  vector<int> a(n);
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    was[x] += 1;
    if (was[x] == 1) first[x] = sum;
    if (x > 0) sum += x;
    last[x] = sum;
  }
  long long bestSum = -LLINF;
  int val = -1;
  for (int i = 0; i < n; ++i) {
    if (was[a[i]] < 2) continue;
    long long cur = last[a[i]] - first[a[i]];
    if (a[i] < 0) cur += 2LL * a[i];
    if (bestSum < cur) {
      bestSum = cur;
      val = a[i];
    }
  }
  cout << bestSum << " ";
  int b, e;
  b = e = -1;
  for (int i = 0; i < n; ++i) {
    if (a[i] == val) {
      if (b == -1) b = i;
      e = i;
    }
  }
  vector<int> toRemove;
  for (int i = 0; i < b; ++i) toRemove.push_back(i);
  for (int i = e + 1; i < n; ++i) toRemove.push_back(i);
  for (int i = b + 1; i < e; ++i)
    if (a[i] < 0) toRemove.push_back(i);
  sort((toRemove).begin(), (toRemove).end());
  cout << toRemove.size() << "\n";
  for (int i = 0; i < toRemove.size(); ++i) printf("%d ", toRemove[i] + 1);
  return 0;
}
