#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 2000;
long long c[maxn], ans = -0x7fffffff, ansi, ansj, a[maxn], b[maxn], top, bot;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] < 0) {
      b[top++] = i;
      c[i] = c[i - 1];
    } else
      c[i] = c[i - 1] + a[i];
  }
  for (int i = 1; i <= n - 1; i++)
    for (int j = n; j > i; j--) {
      long long sum = 0;
      if (a[i] == a[j]) {
        if (a[i] < 0) {
          sum = c[j] - c[i - 1] + a[i] * 2;
        } else
          sum = c[j] - c[i - 1];
        if (sum > ans) {
          ans = sum;
          ansi = i;
          ansj = j;
        }
        break;
      }
    }
  while (bot < top && b[bot] <= ansi) bot++;
  while (top > 0 && b[top - 1] >= ansj) top--;
  cout << ans << ' ' << top - bot + ansi - 1 + n - ansj << endl;
  for (int i = 1; i < ansi; i++) cout << i << ' ';
  for (int i = bot; i < top; i++) cout << b[i] << ' ';
  for (int i = ansj + 1; i <= n; i++) cout << i << ' ';
  return 0;
}
