#include <bits/stdc++.h>
using namespace std;
int n, tab[300], ile, poczatek, koniec, p;
long long suma, maks = -1e18;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &tab[i]);
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++) {
      if (tab[i] == tab[j]) {
        p = 0;
        suma = 2 * tab[i];
        for (int k = i + 1; k < j; k++) (tab[k] >= 0) ? suma += tab[k] : p++;
        if (suma > maks) {
          maks = suma;
          poczatek = i;
          koniec = j;
          ile = poczatek - 1 + n - koniec + p;
        }
      }
    }
  cout << maks << " " << ile << "\n";
  if (ile > 0) {
    for (int i = 1; i < poczatek; i++) printf("%d ", i);
    for (int i = poczatek + 1; i < koniec; i++)
      if (tab[i] < 0) printf("%d ", i);
    for (int i = koniec + 1; i <= n; i++) printf("%d ", i);
    printf("\n");
  }
  return 0;
}
