#include <bits/stdc++.h>
using namespace std;
int i, j;
int b;
pair<int, int> a[300010];
long long sum[300010];
int main() {
  int n;
  cin >> n;
  memset(sum, 0ll, sizeof(sum));
  for (i = 0; i < n; i++) {
    scanf("%d", &b);
    sum[i + 1] += sum[i];
    if (b >= 0) sum[i + 1] += b;
    a[i + 1].first = b;
    a[i + 1].second = i + 1;
  }
  sort(a + 1, a + n + 1);
  long long temp, maxi = -2000000001ll;
  int indi, indj;
  for (i = 1; i <= n; i++) {
    j = i + 1;
    temp = a[i].first;
    while (1) {
      if (a[i].first != a[j].first || j == n) {
        if (j == n && a[i].first == a[j].first)
          j++;
        else if (j == n && i == j)
          break;
        if (i != j - 1) {
          temp += a[i].first;
          temp += (sum[a[j - 1].second] - sum[a[i].second - 1]);
          if (a[i].first >= 0) {
            temp -= (a[i].first * 2);
          }
          if (temp >= maxi) {
            maxi = temp;
            indi = a[i].second;
            indj = a[j - 1].second;
          }
          i = j - 1;
        }
        break;
      }
      j++;
      if (j > n) break;
    }
  }
  int t = 0;
  for (i = 1; i <= n; i++) {
    if (a[i].second < indi)
      t++;
    else if (a[i].second > indj)
      t++;
    else if (a[i].second != indi && a[i].second != indj && a[i].first < 0)
      t++;
  }
  cout << maxi << " " << t << endl;
  for (i = 1; i <= n; i++) {
    if (a[i].second < indi)
      printf("%d ", a[i].second);
    else if (a[i].second > indj)
      printf("%d ", a[i].second);
    else if (a[i].second != indi && a[i].second != indj && a[i].first < 0)
      printf("%d ", a[i].second);
  }
  return 0;
}
