#include <bits/stdc++.h>
std::map<long long, int> first, last;
long long tree[300010];
long long sum[300010];
int ansdel[300010];
int main() {
  int n;
  scanf("%d", &n);
  sum[0] = 0;
  first.clear();
  last.clear();
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &tree[i]);
    if (tree[i] > 0)
      sum[i] = sum[i - 1] + tree[i];
    else
      sum[i] = sum[i - 1];
    if (!first[tree[i]]) first[tree[i]] = i;
    last[tree[i]] = i;
  }
  long long anssum;
  int anspos = -1;
  for (int i = 1; i <= n - 1; i++)
    if (first[tree[i]] == i && last[tree[i]] != i) {
      long long temp = sum[last[tree[i]]] - sum[i - 1];
      if (tree[i] < 0) temp += 2 * tree[i];
      if (anspos == -1 || (anssum < temp)) {
        anspos = i;
        anssum = temp;
      }
    }
  ansdel[0] = 0;
  for (int i = 1; i <= anspos - 1; i++) ansdel[++ansdel[0]] = i;
  for (int i = anspos + 1; i <= last[tree[anspos]] - 1; i++)
    if (tree[i] < 0) ansdel[++ansdel[0]] = i;
  for (int i = last[tree[anspos]] + 1; i <= n; i++) ansdel[++ansdel[0]] = i;
  printf("%I64d %d\n", anssum, ansdel[0]);
  for (int i = 1; i <= ansdel[0]; i++)
    printf("%d%c", ansdel[i], (i == ansdel[0]) ? '\n' : ' ');
  return 0;
}
