#include <bits/stdc++.h>
using namespace std;
vector<long long> v[301], vv, v1;
long long a, b, c[1234567], c1[123][123], d[1234567], e, i, j, n, x, y, l, r, k;
string s, s1;
long long used[301], sum[1234567];
long long ans;
map<long long, long long> m, mm;
int main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> c[i];
    if (c[i] > 0)
      sum[i] = sum[i - 1] + c[i];
    else
      sum[i] = sum[i - 1];
    if (m[c[i]] == 0) {
      m[c[i]] = i;
    }
    mm[c[i]] = i;
  }
  long long l = -1, r = -1, sum2 = -1e15;
  for (auto x : mm) {
    if (m[x.first] == x.second) continue;
    long long sum1 = sum[x.second - 1] - sum[m[x.first]] + 2 * x.first;
    if (sum1 > sum2) {
      sum2 = sum1;
      l = m[x.first];
      r = mm[x.first];
    }
  }
  long long ans = 0;
  for (int i = 1; i < l; i++) {
    ans++;
  }
  for (int i = l + 1; i < r; i++) {
    if (c[i] < 0) {
      ans++;
    }
  }
  for (int i = r + 1; i <= n; i++) {
    ans++;
  }
  cout << sum2 << " " << ans << '\n';
  for (int i = 1; i < l; i++) {
    cout << i << " ";
  }
  for (int i = l + 1; i < r; i++) {
    if (c[i] < 0) {
      cout << i << " ";
    }
  }
  for (int i = r + 1; i <= n; i++) {
    cout << i << " ";
  }
}
