#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
vector<string> parse(string s, string c) {
  int len = c.length(), p = -len, np;
  vector<string> ans;
  do {
    np = s.find(c, p + len);
    ans.push_back(s.substr(p + len, np - p - len));
    p = np;
  } while (p != string::npos);
  return ans;
}
long long in[300009];
long long dp[300009];
long long n;
map<long long, int> mapa;
vector<int> exist;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> in[i];
    if (in[i] > 0)
      dp[i] = dp[i - 1] + in[i];
    else
      dp[i] = dp[i - 1];
    if (mapa.count(in[i]))
      exist.push_back(i);
    else
      mapa[in[i]] = i;
  }
  long long st, ed;
  long long total = -(1LL << 55);
  for (int i = 0; i < exist.size(); i++) {
    int rt = exist[i];
    int lf = mapa[in[rt]];
    long long temp = in[lf] + in[rt];
    temp += dp[rt - 1] - dp[lf];
    if (temp > total) {
      total = temp;
      ed = rt;
      st = lf;
    }
  }
  vector<int> del;
  for (int i = 1; i < st; i++) del.push_back(i);
  for (int i = st + 1; i < ed; i++)
    if (in[i] < 0) del.push_back(i);
  for (int i = ed + 1; i <= n; i++) del.push_back(i);
  cout << total << " " << del.size() << endl;
  for (int i = 0; i < del.size(); i++) cout << del[i] << " ";
  return 0;
}
