#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
const long long oo = 2e9 + 5;
long long sum[MAXN], pos[MAXN], best;
int n, a[MAXN], l, r, ans[MAXN], sz;
map<int, int> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum[i] = a[i];
    if (i) {
      sum[i] += sum[i - 1];
      pos[i] += pos[i - 1];
      if (a[i] > 0) pos[i] += a[i];
    }
    if (mp.count(a[i]) == 0) mp[a[i]] = i;
  }
  best = -oo;
  for (int i = n - 1; i > 0; --i) {
    int tl = mp[a[i]];
    if (tl == i) continue;
    long long tmp = pos[i - 1] - pos[tl] + a[tl] + a[i];
    if (tmp > best) {
      best = tmp;
      l = tl;
      r = i;
    }
  }
  long long sum = ::sum[n - 1];
  for (int i = 0; i < n; ++i) {
    if (i == l || i == r) continue;
    if (a[i] < 0 || i < l || i > r) {
      ans[sz++] = i + 1;
      sum -= a[i];
    }
  }
  cout << sum << " " << sz << endl;
  for (int i = 0; i < sz; ++i) {
    cout << ans[i] << " \n"[i == sz - 1];
  }
  return 0;
}
