#include <bits/stdc++.h>
using namespace std;
long long n, ans, al, ar;
long long a[300009];
long long sum[300009];
long long lisan[300009];
map<long long, long long> mp;
long long ll[300009], rr[300009];
int main() {
  while (scanf("%I64d", &n) != EOF) {
    mp.clear();
    sum[0] = 0;
    long long p = 0;
    for (long long i = 1; i <= n; i++) {
      scanf("%I64d", &a[i]);
      lisan[p++] = a[i];
      if (a[i] > 0)
        sum[i] = sum[i - 1] + a[i];
      else
        sum[i] = sum[i - 1];
      ll[i] = n + 1, rr[i] = 0;
    }
    ll[0] = n + 1;
    rr[0] = 0;
    sort(lisan, lisan + p);
    p = unique(lisan, lisan + p) - lisan;
    for (long long i = 0; i < p; i++) mp[lisan[i]] = i;
    for (long long i = 1; i <= n; i++) {
      long long k = mp[a[i]];
      ll[k] = min(ll[k], i);
      rr[k] = max(rr[k], i);
    }
    ans = -1000000000000000000, al, ar;
    for (long long i = 0; i < p; i++) {
      if (ll[i] < rr[i]) {
        if (ans < sum[rr[i] - 1] - sum[ll[i]] + 2 * a[ll[i]]) {
          ans = sum[rr[i] - 1] - sum[ll[i]] + 2 * a[ll[i]], al = ll[i] + 1;
          ar = rr[i] - 1;
        }
      }
    }
    printf("%I64d ", ans);
    long long sum = 0;
    sum = al - 1 + n - ar - 2;
    for (long long i = al; i <= ar; i++)
      if (a[i] < 0) sum++;
    printf("%I64d\n", sum);
    if (sum) {
      for (long long i = 1; i < al - 1; i++) printf("%I64d ", i);
      for (long long i = al; i <= ar; i++)
        if (a[i] < 0) printf("%I64d ", i);
      for (long long i = ar + 2; i <= n; i++) printf("%I64d ", i);
      printf("\n");
    }
  }
}
