#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long arr[n];
  map<long long, long long> m;
  map<long long, pair<long long, long long> > mp;
  long long sum[n], sumn[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    m[arr[i]]++;
    if (m[arr[i]] == 1) {
      mp[arr[i]].first = i;
    } else
      mp[arr[i]].second = i;
    if (i == 0)
      sum[0] = arr[0];
    else
      sum[i] = sum[i - 1] + arr[i];
    if (i == 0) {
      if (arr[i] < 0)
        sumn[0] = arr[0];
      else
        sumn[0] = 0;
    } else {
      if (arr[i] < 0)
        sumn[i] = sumn[i - 1] + arr[i];
      else
        sumn[i] = sumn[i - 1];
    }
  }
  long long min = 1e18;
  map<long long, long long>::iterator itr;
  long long num;
  for (itr = m.begin(); itr != m.end(); itr++) {
    if ((itr->second) > 1) {
      long long x = itr->first;
      long long l = mp[x].first;
      long long r = mp[x].second;
      long long tmp =
          (sum[l] - arr[l]) + (sum[n - 1] - sum[r]) + (sumn[r - 1] - sumn[l]);
      if (tmp < min) {
        num = x;
        min = tmp;
      }
    }
  }
  long long res = sum[n - 1] - min;
  long long l = mp[num].first;
  long long r = mp[num].second;
  long long count = 0;
  vector<long long> v;
  for (int i = 0; i < n; i++) {
    if (i < l) {
      count++;
      v.push_back(i + 1);
    } else if (i > r) {
      count++;
      v.push_back(i + 1);
    } else if (i > l && i < r) {
      if (arr[i] < 0) {
        count++;
        v.push_back(i + 1);
      }
    }
  }
  cout << res << " " << count << "\n";
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  return 0;
}
