#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> num[300009];
long long sum[300009];
int neg;
int values[300009];
vector<int> answer;
int ultimo(int pos) {
  for (int i = pos + 1; i <= n; i++)
    if (num[i].first != num[pos].first) return i - 1;
  if (num[pos].first == num[n].first) return n;
  return -1;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> num[i].first;
    values[i] = num[i].first;
    num[i].second = i;
    if (num[i].first >= 0)
      sum[i] = sum[i - 1] + num[i].first;
    else
      sum[i] = sum[i - 1];
  }
  sort(num + 1, num + n + 1);
  long long mejor = -1000000000000000;
  int ini = 0;
  int fin = 0;
  for (int i = 1; i <= n; i++) {
    int pos = ultimo(i);
    if (pos <= i) continue;
    if (values[num[i].second] < 0) {
      if (mejor < -sum[num[i].second - 1] + sum[num[pos].second] +
                      2 * values[num[pos].second]) {
        mejor = -sum[num[i].second - 1] + sum[num[pos].second] +
                2 * values[num[pos].second];
        ini = num[i].second;
        fin = num[pos].second;
      }
    } else {
      if (mejor < -sum[num[i].second - 1] + sum[num[pos].second]) {
        mejor = -sum[num[i].second - 1] + sum[num[pos].second];
        ini = num[i].second;
        fin = num[pos].second;
      }
    }
    i = pos;
  }
  int eliminar = ini - 1;
  eliminar += n - fin;
  for (int i = ini + 1; i < fin; i++)
    if (values[i] < 0) eliminar++;
  cout << mejor << " " << eliminar << endl;
  if (eliminar > 0) {
    for (int i = 1; i < ini; i++) answer.push_back(i);
    for (int i = ini + 1; i < fin; i++)
      if (values[i] < 0) answer.push_back(i);
    for (int i = fin + 1; i <= n; i++) answer.push_back(i);
    for (int i = 0; i < answer.size() - 1; i++) {
      cout << answer[i] << " ";
    }
    cout << answer[answer.size() - 1] << endl;
  }
  return 0;
}
