#include <bits/stdc++.h>
using namespace std;
long long leftSum[300010];
long long rightSum[300010];
long long sum;
long long aleftSum[300010];
long long arightSum[300010];
long long asum;
void init(long long n, long long a[300010]) {
  sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    asum += abs(a[i]);
  }
  for (int i = 0; i < n; i++)
    leftSum[i] = rightSum[i] = aleftSum[i] = arightSum[i] = 0;
  leftSum[0] = a[0];
  for (int i = 1; i < n; i++) leftSum[i] = a[i] + leftSum[i - 1];
  aleftSum[0] = abs(a[0]);
  for (int i = 1; i < n; i++) aleftSum[i] = abs(a[i]) + aleftSum[i - 1];
  rightSum[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; i--) rightSum[i] = a[i] + rightSum[i + 1];
  arightSum[n - 1] = abs(a[n - 1]);
  for (int i = n - 2; i >= 0; i--) arightSum[i] = abs(a[i]) + arightSum[i + 1];
}
void output(long long n, long long a[300010], long long sPos, long long ePos,
            long long max) {
  long long cut[300010];
  long long cutCount = 0;
  for (long long i = 0; i < sPos; i++) {
    cut[cutCount] = i + 1;
    cutCount++;
  }
  for (long long i = sPos + 1; i < ePos; i++)
    if (a[i] < 0) {
      cut[cutCount] = i + 1;
      cutCount++;
    }
  for (long long i = ePos + 1; i < n; i++) {
    cut[cutCount] = i + 1;
    cutCount++;
  }
  cout << max << " " << cutCount << endl;
  for (long long i = 0; i < cutCount; i++) cout << cut[i] << " ";
  cout << endl;
}
int main() {
  long long n;
  long long a[300010];
  long long sPos, ePos;
  long long max = -INT_MAX;
  map<long long, long long> m;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]] = i;
  }
  init(n, a);
  for (long long s = 0; s < n; s++)
    if (m[a[s]] != s) {
      long long e = m[a[s]];
      long long tmp =
          (sum - leftSum[s] - rightSum[e] + asum - aleftSum[s] - arightSum[e]) /
              2 +
          a[s] + a[e];
      if (max < tmp) {
        sPos = s;
        ePos = e;
        max = tmp;
      }
    }
  output(n, a, sPos, ePos, max);
  return 0;
}
