#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int nextPrime(int N) {
  if (N <= 1) return 2;
  int prime = N;
  bool found = false;
  while (!found) {
    prime++;
    if (isPrime(prime)) found = true;
  }
  return prime;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int test_case;
  test_case = 1;
  while (test_case--) {
    long long int n;
    cin >> n;
    long long int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long int ma = LONG_MIN, st, en, i, j, k;
    for (i = 0; i < n; i++) {
      long long int ans = 0;
      for (j = n - 1; j > i; j--) {
        if (a[i] == a[j]) {
          for (k = i; k <= j; k++) {
            if (k == i || k == j) {
              ans = ans + a[k];
            } else if (a[k] > 0) {
              ans = ans + a[k];
            }
          }
          if (ans > ma) {
            ma = ans;
            st = i;
            en = j;
          }
          break;
        }
      }
    }
    vector<long long int> v;
    for (i = 0; i < n; i++) {
      if (i < st) {
        v.push_back(i + 1);
      } else if (i > en) {
        v.push_back(i + 1);
      } else if (a[i] < 0 && i != st && i != en) {
        v.push_back(i + 1);
      }
    }
    cout << ma << " " << v.size() << endl;
    for (int i = 0; i < v.size(); i++) {
      cout << v[i] << " ";
    }
  }
}
