#include <bits/stdc++.h>
using namespace std;
long long points[1000000];
long long vice[1000000];
long long dp[1000000];
long long summation_till[1000000];
long long start[1000000];
map<long long, long long> last_appear;
long long INF = 1LL << 55;
int main() {
  long long n_points;
  cin >> n_points;
  for (long long i = 0; i < n_points; i++) {
    scanf("%lld", points + i);
    vice[i] = -1;
  }
  for (long long j = 0; j < n_points; j++) {
    summation_till[j] = points[j];
    if (summation_till[j] < 0) {
      summation_till[j] = 0;
    }
    summation_till[j] += summation_till[j - 1];
    if (last_appear.find(points[j]) != last_appear.end()) {
      vice[j] = last_appear[points[j]];
    }
    last_appear[points[j]] = j;
  }
  dp[0] = 0;
  for (long long i = 0; i < n_points; i++) {
    if (vice[i] == -1) {
      dp[i] = -INF;
      continue;
    }
    dp[i] = summation_till[i - 1] - summation_till[vice[i]];
    start[i] = vice[i];
    if (points[vice[i]] >= 0) {
      if (dp[vice[i]] + points[vice[i]] > 0) {
        dp[i] += dp[vice[i]] + points[vice[i]];
        start[i] = start[vice[i]];
      }
    } else {
      if (dp[vice[i]] > 0) {
        dp[i] += dp[vice[i]];
        start[i] = start[vice[i]];
      }
    }
  }
  long long max = -INF;
  long long max_loc = -1;
  for (long long i = 0; i < n_points; i++) {
    if (dp[i] + 2 * points[i] > max) {
      max = dp[i] + 2 * points[i];
      max_loc = i;
    }
  }
  long long count = 0;
  for (long long i = 0; i < start[max_loc]; i++) {
    count++;
  }
  for (long long i = start[max_loc] + 1; i < max_loc; i++) {
    if (points[i] < 0) {
      count++;
    }
  }
  for (long long i = max_loc + 1; i < n_points; i++) {
    count++;
  }
  cout << max << " " << count << endl;
  for (long long i = 0; i < start[max_loc]; i++) {
    printf("%lld ", i + 1);
  }
  for (long long i = start[max_loc] + 1; i < max_loc; i++) {
    if (points[i] < 0) {
      printf("%lld ", i + 1);
    }
  }
  for (long long i = max_loc + 1; i < n_points; i++) {
    printf("%lld ", i + 1);
  }
}
