#include <bits/stdc++.h>
using namespace std;
long long arr[300100];
long long bit[300100];
int n;
void insert(int x, long long val) {
  for (int i = x; i <= n; i += (i & -i)) bit[i] += val;
}
long long get(int x) {
  long long sum = 0;
  for (int i = x; i > 0; i -= (i & -i)) sum += bit[i];
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  map<int, int> pos;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    if (arr[i] > 0) insert(i, arr[i]);
    pos[arr[i]] = i;
  }
  int pi, pf;
  long long ans = (1e10) * (-1ll), temp;
  int ini, fin;
  for (int i = 1; i < n; i++) {
    if (pos[arr[i]] == i) continue;
    ini = i;
    fin = pos[arr[i]] - 1;
    temp = 0;
    if (ini < fin) {
      temp += get(fin);
      temp -= get(ini);
    }
    temp += arr[i] * 2;
    if (temp > ans) {
      ans = temp;
      pi = ini + 1;
      pf = fin;
    }
  }
  int cont = 0;
  vector<int> nums;
  cont += pi - 2;
  cont += n - pf - 1;
  for (int i = 1; i < pi - 1; i++) nums.push_back(i);
  for (int i = pi; i <= pf; i++) {
    if (arr[i] < 0) {
      nums.push_back(i);
      cont++;
    }
  }
  for (int i = pf + 2; i <= n; i++) nums.push_back(i);
  cout << ans << " " << cont << "\n";
  for (int i = 0; i < nums.size(); i++)
    if (i)
      cout << " " << nums[i];
    else
      cout << nums[i];
  return 0;
}
