#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
long long n, x, sum, max_sum, res1, res2, s[1000000], a[1000000], l, r;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mp[a[i]] = i;
    s[i] = s[i - 1];
    if (a[i] > 0) s[i] += a[i];
  }
  max_sum = -100000000000LL;
  for (int i = 1; i <= n; i++) {
    x = mp[a[i]];
    if (x == i) continue;
    sum = s[x] - s[i - 1];
    if (a[i] < 0) sum += 2 * a[i];
    if (sum > max_sum) {
      l = i;
      r = x;
      max_sum = sum;
    }
  }
  res1 = max_sum;
  res2 = l - 1 + n - r;
  for (int i = l + 1; i < r; i++)
    if (a[i] < 0) res2++;
  cout << res1 << " " << res2 << "\n";
  for (int i = 1; i < l; i++) cout << i << " ";
  for (int i = l + 1; i < r; i++)
    if (a[i] < 0) cout << i << " ";
  for (int i = r + 1; i <= n; i++) cout << i << " ";
  return 0;
}
