#include <bits/stdc++.h>
const double eps = 1e-9;
const double pi = acos(-1);
const long long oo = 1000000000000000000LL;
const int mod = 1000000007;
const double E = 2.7182818284590452353602874713527;
using namespace std;
long long s[100001];
int a[100001];
map<int, int> h;
int main() {
  int n, l, r, ans = 0;
  long long res = -oo;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s[i] = s[i - 1] + max(0, a[i]);
  }
  for (int i = 1; i <= n; i++)
    if (h.count(a[i])) {
      if (s[i - 1] - s[h[a[i]]] + 2 * a[i] > res) {
        res = s[i - 1] - s[h[a[i]]] + 2 * a[i];
        l = h[a[i]];
        r = i;
      }
    } else
      h[a[i]] = i;
  for (int i = 1; i <= n; i++)
    if (i < l || i > r || (a[i] < 0 && i > l && i < r)) ans++;
  cout << res << ' ' << ans << endl;
  for (int i = 1; i <= n; i++)
    if (i < l || i > r || (a[i] < 0 && i > l && i < r)) printf("%d ", i);
  return 0;
}
