#include <bits/stdc++.h>
using namespace std;
const int MaxN = 3e5 + 5;
int box[MaxN], del[MaxN];
long long presum[MaxN];
long long sum;
int l, r, n;
map<int, int> pos;
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%d", &box[i]);
    for (int i = n; i >= 1; i--) pos[box[i]] = i;
    for (int i = 1; i <= n; i++)
      if (box[i] >= 0)
        presum[i] = presum[i - 1] + box[i];
      else
        presum[i] = presum[i - 1];
    r = l = 0;
    sum = -(1LL << 60);
    for (int i = 1; i <= n; i++) {
      if (i == pos[box[i]]) continue;
      long long temp;
      if (pos[box[i]] == i - 1)
        temp = 2LL * box[i];
      else
        temp = 2LL * box[i] + presum[i - 1] - presum[pos[box[i]]];
      if (temp > sum) {
        sum = temp;
        r = i;
        l = pos[box[i]];
      }
    }
    int discont = 0;
    for (int i = 1; i <= n; i++) {
      if (i < l || i > r)
        del[++discont] = i;
      else if (box[i] < 0 && i != l && i != r)
        del[++discont] = i;
    }
    printf("%lld %d\n", sum, discont);
    for (int i = 1; i <= discont; i++) printf("%d ", del[i]);
    printf("\n");
    pos.clear();
    memset(del, 0, sizeof(del));
    memset(presum, 0, sizeof(presum));
  }
  return 0;
}
