#include <bits/stdc++.h>
using namespace std;
using namespace std;
void chekarre(int* arr, int n) {
  cout << "[";
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  cout << "]" << endl;
}
int n, m, negtot = 0;
int a[300005] = {0};
long long sm[300005] = {0};
map<int, int> mp;
map<int, int>::iterator it;
int solve() {
  if (n == 2) {
    cout << a[1] + a[2] << " 0";
    return 1;
  }
  int left = 0, right = 0;
  long long mx = -1000000000000000, tmp;
  for (int i = 1; i < n + 1; i++) {
    it = mp.find(a[i]);
    if (it != mp.end() && mp[a[i]] != i) {
      tmp = sm[mp[a[i]]] - sm[i];
      if (a[i] > 0) {
        tmp += a[i];
      } else {
        tmp += a[i];
        tmp += a[i];
      }
      if (tmp > mx) {
        mx = tmp;
        left = i;
        right = mp[a[i]];
      }
    }
  }
  negtot = 0;
  cout << mx << " ";
  negtot += (left - 1);
  negtot += (n - right);
  for (int i = left + 1; i < right; i++) {
    if (a[i] < 0) negtot++;
  }
  cout << negtot << endl;
  if (negtot == 0) return 1;
  for (int i = 1; i < left; i++) {
    cout << i << " ";
  }
  for (int i = left + 1; i < right; i++) {
    if (a[i] < 0) cout << i << " ";
  }
  for (int i = right + 1; i < n + 1; i++) {
    cout << i << " ";
  }
  return 1;
}
bool input() {
  scanf("%d", &n);
  a[0] = 0;
  sm[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    scanf("%d", &a[i]);
    if (a[i] > 0)
      sm[i] = sm[i - 1] + a[i];
    else
      sm[i] = sm[i - 1];
    mp[a[i]] = i;
  }
  return true;
}
int main() {
  int T = 1;
  for (int testnum = 1; testnum <= T; testnum++) {
    if (!input()) break;
    solve();
  }
  return 0;
}
