#include <bits/stdc++.h>
using namespace std;
const int NMax = 301000, MMax = 200;
int N, A[NMax];
map<int, int> S;
long long sum[NMax];
vector<int> R;
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", A + i);
    S[A[i]] = max(S[A[i]], i);
    if (A[i] >= 0)
      sum[i] = sum[i - 1] + A[i];
    else
      sum[i] = sum[i - 1];
  }
  long long maxx = -(~0uLL >> 1);
  pair<int, int> ans;
  for (int i = 1; i <= N; i++) {
    int t = S[A[i]];
    if (t > i) {
      long long first = sum[t] - sum[i - 1];
      if (A[i] < 0) first += (long long)A[i] * 2;
      if (first > maxx) {
        maxx = first;
        ans = make_pair(i, t);
      }
    }
  }
  printf("%I64d ", maxx);
  for (int i = 1; i < ans.first; i++) R.push_back(i);
  for (int i = ans.first + 1; i < ans.second; i++)
    if (A[i] < 0) R.push_back(i);
  for (int i = ans.second + 1; i <= N; i++) R.push_back(i);
  printf("%d\n", (int)R.size());
  for (int i = 0; i < R.size(); i++) printf("%d ", R[i]);
  puts("");
  return 0;
}
