#include <bits/stdc++.h>
using namespace std;
int data[100005 * 3];
long long total[3 * 100005];
map<int, int> pos;
set<int> anss;
int main() {
  int n;
  cin >> n;
  data[0] = total[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &data[i]);
    total[i] = max(0, data[i]);
  }
  for (int i = 2; i <= n; i++) total[i] += total[i - 1];
  for (int i = 1; i <= n; i++)
    if (pos[data[i]] == 0) pos[data[i]] = i;
  long long ans = -(1LL << 60);
  int l, r;
  for (int i = n; i >= 1; i--)
    if (pos[data[i]] > 0 && i - pos[data[i]] > 0 &&
        (total[i - 1] - total[pos[data[i]]] + (2LL * (long long)(data[i]))) >
            ans)
      ans = (total[i - 1] - total[pos[data[i]]] + (2LL * (long long)(data[i]))),
      l = pos[data[i]] - 1, r = i + 1;
  for (int i = 1; i <= l; i++) anss.insert(i);
  for (int i = r; i <= n; i++) anss.insert(i);
  for (int i = l + 2; i < r - 1; i++)
    if (data[i] < 0) anss.insert(i);
  printf("%I64d %d", ans, anss.size());
  puts("");
  for (set<int>::iterator it = anss.begin(); it != anss.end(); it++)
    printf("%d ", *it);
  return 0;
}
