#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
int n, nums[300009];
map<int, int> first;
long long acc[300009];
int main() {
  scanf("%d", &n);
  long long ret = (long long)-1e16;
  int st, en;
  for (int i = 1; i < (int)(n + 1); i++) {
    scanf("%d", &nums[i]);
    acc[i] = acc[i - 1];
    if (nums[i] >= 0) acc[i] += nums[i];
    if (first.count(nums[i])) {
      int from = first[nums[i]];
      long long sum = acc[i] - acc[from - 1];
      if (nums[i] < 0) sum += 2 * nums[i];
      if (sum > ret) {
        ret = sum;
        st = from;
        en = i;
      }
    } else
      first[nums[i]] = i;
  }
  int cnt = 0;
  cnt += st - 1;
  cnt += n - en;
  for (int i = st + 1; i < (int)(en); i++)
    if (nums[i] < 0) cnt++;
  cout << ret << " " << cnt << endl;
  string s = "";
  for (int i = 1; i < (int)(st); i++) {
    cout << s << i;
    s = " ";
  }
  for (int i = st + 1; i < (int)(en); i++)
    if (nums[i] < 0) {
      cout << s << i;
      s = " ";
    }
  for (int i = en + 1; i < (int)(n + 1); i++) {
    cout << s << i;
    s = " ";
  }
  cout << endl;
  return 0;
}
