#include <bits/stdc++.h>
using namespace std;
int n;
long long a[300010], s[300010];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + max(a[i], 0LL);
  map<int, int> mp;
  long long ans = (long long)-1e15;
  int al = -1, ar = -1;
  for (int i = 1; i <= n; i++) {
    if (mp.count(a[i])) {
      int j = mp[a[i]];
      long long now = a[i] + a[j] + s[i - 1] - s[j];
      if (now > ans) {
        ans = now;
        al = j;
        ar = i;
      }
      if (a[i] - s[i] > a[j] - s[j]) mp[a[i]] = i;
    } else {
      mp[a[i]] = i;
    }
  }
  vector<int> sol;
  for (int i = 1; i < al; i++) sol.push_back(i);
  for (int i = al + 1; i < ar; i++)
    if (a[i] < 0) sol.push_back(i);
  for (int i = ar + 1; i <= n; i++) sol.push_back(i);
  cout << ans << " " << ((int)(sol).size()) << endl;
  for (int i = 0; i < ((int)(sol).size()); i++)
    printf("%d%c", sol[i], i + 1 == ((int)(sol).size()) ? '\n' : ' ');
  return 0;
}
