#include <bits/stdc++.h>
using namespace std;
class Numbers {
 public:
  Numbers(long long n) {
    nums.push_back(n);
    count = 1;
  }
  Numbers() { count = 0; }
  void add(long long n) {
    nums.push_back(n);
    count++;
  }
  std::list<long long> nums;
  int count;
};
void build(long long *t, long long *a, int v, int tl, int tr) {
  if (tl == tr)
    t[v] = max(a[tl], (long long)0);
  else {
    int tm = (tl + tr) / 2;
    build(t, a, v * 2, tl, tm);
    build(t, a, v * 2 + 1, tm + 1, tr);
    t[v] = max(t[v * 2], (long long)0) + max(t[v * 2 + 1], (long long)0);
  }
}
long long sum(long long *t, int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (l == tl && r == tr) return t[v];
  int tm = (tl + tr) / 2;
  return sum(t, v * 2, tl, tm, l, min(r, tm)) +
         sum(t, v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}
int main() {
  int n;
  std::cin >> n;
  long long *t = new long long[4 * n];
  long long *forest = new long long[n];
  std::map<long long, Numbers> fort;
  std::vector<long long> cover(n);
  for (int i = 0; i < n; i++) {
    std::cin >> forest[i];
    fort[forest[i]].add(i);
    cover[i] = i;
  }
  build(t, forest, 1, 0, n - 1);
  long long **couples = new long long *[(n / 2) + 1];
  for (int i = 0; i < n / 2 + 1; i++) {
    couples[i] = new long long[2];
  }
  int couple_count = 0;
  for (std::map<long long, Numbers>::iterator it = fort.begin();
       it != fort.end(); ++it) {
    if (it->second.count > 1) {
      couples[couple_count][0] = *(it->second.nums.begin());
      couples[couple_count][1] = *(--(it->second.nums.end()));
      couple_count++;
    }
  }
  long long max = -100000000000000000;
  int num = 0;
  for (int i = 0; i < couple_count; i++) {
    long long su = 0;
    su += sum(t, 1, 0, n - 1, couples[i][0] + 1, couples[i][1] - 1);
    su = su + forest[couples[i][0]] + forest[couples[i][1]];
    if (su > max) {
      max = su;
      num = i;
    }
  }
  delete[] t, fort;
  std::vector<int> toDelete;
  int del = 0;
  del = del + couples[num][0] + (n - 1 - couples[num][1]);
  for (int i = couples[num][0] + 1; i < couples[num][1]; i++)
    if (forest[i] < 0) {
      del++;
      toDelete.push_back(i);
    }
  std::cout << max << " " << del << std::endl;
  for (int i = 0; i < couples[num][0]; i++) std::cout << i + 1 << " ";
  for (std::vector<int>::iterator it = toDelete.begin(); it != toDelete.end();
       it++)
    std::cout << *(it) + 1 << " ";
  for (int i = couples[num][1] + 1; i < n; i++) std::cout << i + 1 << " ";
  return 0;
}
