#include <bits/stdc++.h>
using namespace std;
inline long long minOf(long long x, long long y) { return (x < y ? x : y); }
inline long long maxOf(long long x, long long y) { return (x > y ? x : y); }
char arr[50000000], *ptr;
long long ret;
string str;
inline long long get_int() {
  bool isNeg = false;
  ret = 0;
  while (!((*ptr >= '0' && *ptr <= '9') || *ptr == '-')) ptr++;
  while ((*ptr >= '0' && *ptr <= '9') || *ptr == '-') {
    if (*ptr == '-')
      isNeg = true;
    else
      ret = ret * 10 + (*ptr - '0');
    ptr++;
  }
  if (isNeg) ret = -ret;
  return ret;
}
int main() {
  fread(arr, sizeof(char), 50000000, stdin);
  ptr = arr;
  long long trees[300005];
  long long n = get_int();
  for (int i = 0; i < n; i++) {
    trees[i] = get_int();
  }
  long long maxSum = -2000000002;
  int mi = -1, mj = -1;
  long long tms;
  for (int i = 0; i < n - 1; i++) {
    tms = 0;
    for (int j = i + 1; j < n; j++) {
      tms = 0;
      if (trees[i] != trees[j]) continue;
      for (int k = i + 1; k < j; k++) {
        if (trees[k] >= 0) tms = tms + trees[k];
      }
      tms += (trees[i] + trees[j]);
      if (tms >= maxSum) {
        mi = i;
        mj = j;
        maxSum = tms;
      }
    }
  }
  vector<int> toCut;
  for (int i = 0; i < mi; i++) {
    toCut.push_back(i + 1);
  }
  for (int i = mi + 1; i <= mj - 1; i++) {
    if (trees[i] < 0) {
      toCut.push_back(i + 1);
    }
  }
  for (int i = mj + 1; i < n; i++) {
    toCut.push_back(i + 1);
  }
  cout << maxSum << " " << toCut.size() << endl;
  for (int i = 0; i < toCut.size(); i++) {
    cout << toCut[i] << " ";
  }
  cout << endl;
  return 0;
}
