#include <bits/stdc++.h>
using namespace std;
long long arr[101];
int main() {
  int i, j, k;
  int n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) cin >> arr[i];
  long long mx = -INT_MAX, st, ed;
  for (i = 0; i < n; i++) {
    long long cn = arr[i];
    for (j = n - 1; j > i; j--) {
      if (cn == arr[j]) {
        long long sum = 0;
        for (k = i + 1; k < j; k++) {
          if (arr[k] > 0) {
            sum += arr[k];
          }
        }
        sum += (arr[i] * 2);
        if (sum > mx) {
          st = i;
          ed = j;
          mx = sum;
        }
      }
    }
  }
  long long ans = 0;
  vector<long> res;
  for (i = 0; i < n; i++) {
    if (i == st || i == ed) continue;
    if (i < st || i > ed)
      res.push_back(i);
    else if (arr[i] < 0)
      res.push_back(i);
    else
      ans += arr[i];
  }
  cout << mx << " " << res.size() << endl;
  if (res.size()) cout << res[0] + 1;
  for (i = 1; i < res.size(); i++) cout << " " << res[i] + 1;
  return 0;
}
