#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, tot, mx = -10000000000;
  int arr[110], lft, rgt;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++)
    for (int j = n - 1; j > i; j--) {
      if (arr[i] == arr[j]) {
        tot = 0;
        for (int k = i; k <= j; k++)
          if (arr[k] >= 0 || k == i || k == j) tot += arr[k];
        if (tot > mx) {
          mx = tot;
          lft = i;
          rgt = j;
        }
        break;
      }
    }
  int cnt = 0;
  for (int i = 0; i < lft; i++) cnt++;
  for (int i = rgt + 1; i < n; i++) cnt++;
  for (int i = lft + 1; i < rgt; i++)
    if (arr[i] < 0) cnt++;
  cout << mx << " " << cnt << endl;
  for (int i = 0; i < lft; i++) cout << i + 1 << " ";
  for (int i = lft + 1; i < rgt; i++)
    if (arr[i] < 0) cout << i + 1 << " ";
  for (int i = rgt + 1; i < n; i++) cout << i + 1 << " ";
  return 0;
}
