#include <bits/stdc++.h>
using namespace std;
long long arr[(3 * 100000) + 100];
long long cum[(3 * 100000) + 100];
long long getIt(int i, int j) {
  long long ret = cum[j];
  if (i != 0) {
    ret -= cum[i - 1];
  }
  if (arr[i] < 0) ret += arr[i];
  if (arr[j] < 0) ret += arr[j];
  return ret;
}
int main() {
  int n;
  cin >> n;
  int num;
  for (int i = 0; i < n; i++) {
    scanf("%d", &num);
    arr[i] = num;
    if (i != 0) {
      cum[i] = cum[i - 1];
    }
    if (num > 0) cum[i] += num;
  }
  long long mx = -(1LL << 50LL);
  int curi = -1;
  int curj = -1;
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    if (m.find(arr[i]) == m.end()) {
      m[arr[i]] = i;
    } else {
      long long cur = getIt(m[arr[i]], i);
      if (cur > mx) {
        mx = cur;
        curi = m[arr[i]];
        curj = i;
      }
    }
  }
  vector<int> ret;
  for (int i = 0; i < curi; i++) {
    ret.push_back(i + 1);
  }
  for (int i = curi + 1; i < curj; i++) {
    if (arr[i] < 0) ret.push_back(i + 1);
  }
  for (int i = curj + 1; i < n; i++) {
    ret.push_back(i + 1);
  }
  cout << mx << " " << ret.size() << endl;
  for (int i = 0; i < ret.size(); i++) {
    if (i == 0)
      cout << ret[i];
    else
      cout << " " << ret[i];
  }
  cout << endl;
  return 0;
}
