#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005;
int N;
long long a[MAXN];
long long l[MAXN];
long long s[MAXN];
long long n[MAXN];
set<long long> st;
map<long long, int> mp;
int main() {
  cin >> N;
  fill(l, l + N, -1);
  s[0] = 0;
  n[0] = 0;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    s[i + 1] = a[i] + s[i];
    n[i + 1] = (a[i] > 0 ? 0 : a[i]) + n[i];
    if (st.count(a[i]) != 0) {
      int first = mp[a[i]];
      l[first] = ((l[first]) > (i) ? (l[first]) : (i));
    } else {
      mp[a[i]] = i;
    }
    st.insert(a[i]);
  }
  long long ans = LLONG_MIN;
  int al = -1, ar = -1;
  for (int i = 0; i < N; ++i) {
    if (l[i] == -1) continue;
    int left = i;
    int right = l[i];
    long long pos = s[right + 1] - s[left] - n[right] + n[left + 1];
    if (ans < pos) {
      al = left;
      ar = right;
      ans = pos;
    }
  }
  int k = al + N - ar - 1;
  for (int i = al + 1; i < ar; ++i) {
    if (a[i] < 0) {
      ++k;
    }
  }
  cout << ans << ' ' << k << '\n';
  for (int i = 0; i < al; ++i) {
    cout << (i + 1) << ' ';
  }
  for (int i = al + 1; i < ar; ++i) {
    if (a[i] < 0) {
      cout << (i + 1) << ' ';
    }
  }
  for (int i = ar + 1; i < N; ++i) {
    cout << (i + 1) << ' ';
  }
  cout << '\n';
  return 0;
}
