#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300010;
long long sum[MAXN];
int a[MAXN];
map<int, int> mp;
vector<int> vec;
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    sum[0] = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      sum[i] = sum[i - 1];
      if (a[i] > 0) sum[i] += a[i];
    }
    mp.clear();
    mp[a[1]] = 1;
    int ans1, ans2;
    long long Max = -1000000000000000LL;
    for (int i = 2; i <= n; i++) {
      if (mp.find(a[i]) != mp.end()) {
        long long temp = sum[i - 1] - sum[mp[a[i]]] + a[i] + a[mp[a[i]]];
        if (temp > Max) {
          Max = temp;
          ans1 = mp[a[i]];
          ans2 = i;
        }
      } else
        mp[a[i]] = i;
    }
    cout << Max << " ";
    vec.clear();
    for (int i = 1; i < ans1; i++) vec.push_back(i);
    for (int i = ans1 + 1; i < ans2; i++)
      if (a[i] <= 0) vec.push_back(i);
    for (int i = ans2 + 1; i <= n; i++) vec.push_back(i);
    printf("%d\n", vec.size());
    for (int i = 0; i < vec.size(); i++) {
      printf("%d", vec[i]);
      if (i < vec.size() - 1)
        printf(" ");
      else
        printf("\n");
    }
  }
  return 0;
}
