#include <bits/stdc++.h>
using namespace std;
long long a[300010];
long long dp[300010];
map<long long, long long> mp;
vector<int> cc;
int main() {
  int n;
  scanf("%d", &n);
  dp[0] = 0;
  mp.clear();
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    if (a[i] > 0)
      dp[i] = dp[i - 1] + a[i];
    else
      dp[i] = dp[i - 1];
  }
  long long ans = -2e18;
  int x = 1, y = 1;
  for (int i = 1; i <= n; i++) {
    if (mp[a[i]] == 0)
      mp[a[i]] = i;
    else {
      if (dp[i - 1] - dp[mp[a[i]]] + 2 * a[i] > ans) {
        ans = dp[i - 1] - dp[mp[a[i]]] + 2 * a[i];
        x = mp[a[i]];
        y = i;
      }
    }
  }
  printf("%I64d ", ans);
  int cnt = 0;
  for (int i = x + 1; i < y; i++)
    if (a[i] < 0) cnt++;
  cnt += x - 1 + n - y;
  printf("%d\n", cnt);
  for (int i = 1; i < x; i++) printf("%d ", i);
  for (int i = x + 1; i < y; i++)
    if (a[i] < 0) printf("%d ", i);
  for (int i = y + 1; i <= n; i++) printf("%d ", i);
  printf("\n");
  return 0;
}
