#include <bits/stdc++.h>
using namespace std;
int n, tree[300005];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> tree[i];
  long long neg, ans, ta, inf = 1ll << 60;
  vector<int> pik, tmp;
  ans = -inf;
  for (int i = 0; i < n; i++) {
    tmp.clear();
    tmp.push_back(i);
    ta = tree[i];
    bool p = 0;
    for (int j = i + 1; j < n; j++) {
      if (tree[i] == tree[j]) {
        if (ans < ta + tree[j]) {
          ans = ta + tree[j];
          pik = tmp;
          pik.push_back(j);
        }
      }
      if (tree[j] > 0) ta += tree[j], tmp.push_back(j);
    }
  }
  cout << ans << ' ' << n - pik.size() << endl;
  bool vis[300005] = {0};
  for (int i = 0; i < pik.size(); i++) vis[pik[i]] = 1;
  for (int i = 0; i < n; i++)
    if (!vis[i]) cout << i + 1 << ' ';
  return 0;
}
