#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[105];
long long v[105];
long long vv[105];
int main() {
  cin >> n;
  long long i, j, k, z, mark;
  long long sum;
  long long ct;
  long long ii;
  long long mmark;
  long long cct = 0;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long max = -2000000001;
  mark = -1;
  ct = 0;
  for (i = 1; i <= n - 1; i++) {
    for (j = i + 1; j <= n; j++) {
      if (a[i] == a[j]) {
        mark = j;
      }
    }
    if (mark != -1) {
      sum = a[i] + a[mark];
      for (k = i + 1; k < mark; k++) {
        if (a[k] > 0)
          sum += a[k];
        else {
          ct++;
          v[k] = 1;
        }
      }
      if (sum > max) {
        ii = i;
        max = sum;
        mmark = mark;
        cct = ct;
        for (z = 1; z <= n; z++) vv[z] = v[z];
      }
    }
    mark = -1;
    ct = 0;
    memset(v, 0, sizeof(v));
  }
  cout << max << " " << cct + ii - 1 + n - mmark << endl;
  int flag = 1;
  for (i = 1; i < ii; i++) {
    flag = 0;
    if (i == 1)
      printf("%d", i);
    else
      printf(" %d", i);
  }
  for (i = ii; i <= mmark; i++) {
    if (vv[i]) {
      if (flag) {
        printf("%d", i);
        flag = 0;
      } else
        printf(" %d", i);
    }
  }
  for (i = mmark + 1; i <= n; i++) {
    if (flag)
      printf("%d", i);
    else
      printf(" %d", i);
  }
  printf("\n");
  return 0;
}
