#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3 * 100000 + 10;
const long long INF = (long long)1e+18;
int n, a[MAXN];
long long sum[MAXN], sum_posi[MAXN];
map<int, int> p;
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    sum[i] = sum[i - 1] + x;
    if (x > 0)
      sum_posi[i] = sum_posi[i - 1] + x;
    else
      sum_posi[i] = sum_posi[i - 1];
    p[x] = i;
  }
}
long long CC = -INF;
int L, R;
void Renew(long long x, int l, int r) {
  if (x > CC) {
    CC = x;
    L = l, R = r;
  }
}
void solve() {
  for (int i = 1; i <= n; ++i) {
    int l = i, r = p[a[i]];
    if (l >= r) continue;
    Renew(sum_posi[r - 1] - sum_posi[l] + a[l] + a[r], l, r);
  }
  int cnt = 0;
  cnt += L - 1 + (n - R);
  for (int i = L + 1; i < R; ++i)
    if (a[i] < 0) ++cnt;
  cout << CC << " " << cnt << endl;
  for (int i = 1; i <= n; ++i)
    if ((i < L) || (i > R) || (a[i] < 0 && i != L && i != R)) printf("%d ", i);
  puts("");
}
int main() {
  init();
  solve();
  fclose(stdin);
  fclose(stdout);
  return 0;
}
