#include <bits/stdc++.h>
using namespace std;
long long int n, a[100007], pref[100007];
map<long long int, long long int> occ;
int main() {
  cin >> n;
  long long int maxn = INT_MIN, x = 1, y = n;
  for (long long int i = 1; i <= n; ++i) cin >> a[i];
  for (long long int i = 1; i <= n; ++i) {
    for (long long int j = i + 1; j <= n; ++j) {
      if (a[i] != a[j]) continue;
      long long int cnt = 0;
      for (long long int k = i + 1; k <= j - 1; ++k) {
        if (a[k] >= 0) {
          cnt += a[k];
        }
      }
      cnt += a[j], cnt += a[i];
      if (cnt > maxn) {
        maxn = cnt;
        x = i;
        y = j;
      }
    }
  }
  long long int negcount = 0;
  for (long long int i = x + 1; i <= y - 1; ++i)
    if (a[i] < 0) negcount++;
  cout << maxn << ' ' << n - (y - x + 1) + negcount << endl;
  for (long long int i = 1; i <= n; ++i)
    if ((a[i] < 0 && i != x && i != y) || i < x || i > y) cout << i << ' ';
  return 0;
}
