#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
long long mas[1000100];
long long dmas[1000100];
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  long long x;
  long long ans = -100000000000000000;
  int ansl, ansr;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    dmas[i] = x;
    if (x >= 0) mas[i] = x;
    if (i > 0) mas[i] += mas[i - 1];
    if (mp.count(x) == 0)
      mp[x] = i;
    else {
      long long d = 0;
      if (x < 0) d = x * 2;
      ans = max(ans, mas[i] - mas[mp[x] - 1] + d);
      if (ans == mas[i] - mas[mp[x] - 1] + d) {
        ansl = mp[x];
        ansr = i;
      }
    }
  }
  cout << ans << " ";
  int c = 0;
  for (int i = 0; i < n; ++i) {
    if (i < ansl)
      ++c;
    else if (i > ansr)
      ++c;
    else if (i < ansr && i > ansl && dmas[i] < 0)
      ++c;
  }
  cout << c << "\n";
  for (int i = 0; i < n; ++i) {
    if (i < ansl)
      cout << i + 1 << " ";
    else if (i > ansr)
      cout << i + 1 << " ";
    else if (i < ansr && i > ansl && dmas[i] < 0)
      cout << i + 1 << " ";
  }
  return 0;
}
