#include <bits/stdc++.h>
using namespace std;
int* a;
long long GetAttr(int i, int j) {
  long long attr = a[i] + a[j];
  for (int k = i + 1; k < j; k++) {
    if (a[k] > 0) attr += a[k];
  }
  return attr;
}
int main(int argc, char** argv) {
  int N;
  cin >> N;
  long long max_attr = -372036854775808;
  int max_i = 0;
  int max_j = N;
  a = new int[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      if (a[i] == a[j]) {
        long long temp_attr = GetAttr(i, j);
        if (temp_attr > max_attr) {
          max_attr = temp_attr;
          max_i = i;
          max_j = j;
        }
      }
    }
  }
  int count = 0;
  for (int i = max_i + 1; i < max_j; i++) {
    if (a[i] < 0) count++;
  }
  cout << max_attr << " " << (max_i + N - max_j - 1 + count) << endl;
  for (int i = 0; i < max_i; i++) {
    cout << i + 1 << " ";
  }
  for (int i = max_i + 1; i < max_j; i++) {
    if (a[i] < 0) cout << i + 1 << " ";
  }
  for (int i = max_j + 1; i < N; i++) {
    cout << i + 1 << " ";
  }
  return 0;
}
