#include <bits/stdc++.h>
using namespace std;
const int MX = 100005, INF = 1000000000, mod = 1000000009;
const long long int LINF = 1000000000000000000ll;
const double eps = 1e-9;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
int a[MX];
long long int b[MX];
pair<int, int> p[MX];
vector<int> c;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    p[i] = pair<int, int>(a[i], i);
  }
  sort(p, p + n);
  for (int i = 0; i < n; i++) b[i] = max(0, a[i]);
  for (int i = 1; i <= n; i++) b[i] += b[i - 1];
  int h, pre;
  pair<long long int, int> ans = pair<long long int, int>(-LINF, 0);
  for (int i = 0; i < n; i++) {
    h = a[i];
    pre = lower_bound(p, p + n, pair<int, int>(h, 0)) - p;
    if (p[pre].second == i) continue;
    int j = p[pre].second;
    ans = max(ans, pair<long long int, int>(h * 2 + b[i - 1] - b[j], i));
  }
  pre = lower_bound(p, p + n, pair<int, int>(a[ans.second], 0)) - p;
  int l = p[pre].second, r = ans.second;
  for (int i = 0; i < l; i++) c.push_back(i);
  for (int i = l + 1; i < r; i++)
    if (a[i] < 0) c.push_back(i);
  for (int i = r + 1; i < n; i++) c.push_back(i);
  cout << ans.first << " " << c.size() << endl;
  for (int i = 0; i < c.size(); i++)
    printf("%d%c", c[i] + 1, i == c.size() - 1 ? '\n' : ' ');
  return 0;
}
