#include <bits/stdc++.h>
using namespace std;
void qSort(long long **a, int first, int last) {
  long long i = first, j = last, x = a[(first + last) / 2][0];
  do {
    while (a[i][0] < x) i++;
    while (a[j][0] > x) j--;
    if (i <= j) {
      if (i < j) {
        long long tmp0, tmp1;
        tmp0 = a[i][0];
        tmp1 = a[i][1];
        a[i][0] = a[j][0];
        a[i][1] = a[j][1];
        a[j][0] = tmp0;
        a[j][1] = tmp1;
      }
      i++;
      j--;
    }
  } while (i <= j);
  if (i < last) qSort(a, i, last);
  if (first < j) qSort(a, first, j);
}
void build(long long *t, long long *a, int v, int tl, int tr) {
  if (tl == tr)
    t[v] = max(a[tl], (long long)0);
  else {
    int tm = (tl + tr) / 2;
    build(t, a, v * 2, tl, tm);
    build(t, a, v * 2 + 1, tm + 1, tr);
    t[v] = max(t[v * 2], (long long)0) + max(t[v * 2 + 1], (long long)0);
  }
}
long long sum(long long *t, int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (l == tl && r == tr) return t[v];
  int tm = (tl + tr) / 2;
  return sum(t, v * 2, tl, tm, l, min(r, tm)) +
         sum(t, v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}
int main() {
  int n;
  std::cin >> n;
  long long *t = new long long[4 * n];
  long long *forest = new long long[n];
  long long **_forest = new long long *[n];
  for (int i = 0; i < n; i++) _forest[i] = new long long[2];
  long long tmp;
  for (int i = 0; i < n; i++) {
    std::cin >> tmp;
    forest[i] = tmp;
    _forest[i][0] = tmp;
    _forest[i][1] = i;
  }
  qSort(_forest, 0, n - 1);
  build(t, forest, 1, 0, n - 1);
  long long **couples = new long long *[(n / 2) + 1];
  for (int i = 0; i < n / 2 + 1; i++) couples[i] = new long long[2];
  int couple_count = 0;
  long long now = -1000000000000000000;
  int i = 0;
  while (i < n) {
    now = _forest[i][0];
    int min = n, max = 0;
    while (i < n && _forest[i][0] == now) {
      if (_forest[i][1] < min) min = _forest[i][1];
      if (_forest[i][1] > max) max = _forest[i][1];
      i++;
    }
    if (min != max && max != 0) {
      couples[couple_count][0] = min;
      couples[couple_count][1] = max;
      couple_count++;
    }
  }
  long long max = -100000000000000000;
  int num = 0;
  for (int i = 0; i < couple_count; i++) {
    long long su = 0;
    su += sum(t, 1, 0, n - 1, couples[i][0] + 1, couples[i][1] - 1);
    su = su + forest[couples[i][0]] + forest[couples[i][1]];
    if (su > max) {
      max = su;
      num = i;
    }
  }
  std::vector<int> toDelete;
  int del = 0;
  del = del + couples[num][0] + (n - 1 - couples[num][1]);
  for (int i = couples[num][0] + 1; i < couples[num][1]; i++)
    if (forest[i] < 0) {
      del++;
      toDelete.push_back(i);
    }
  std::cout << max << " " << del << std::endl;
  for (int i = 0; i < couples[num][0]; i++) std::cout << i + 1 << " ";
  for (std::vector<int>::iterator it = toDelete.begin(); it != toDelete.end();
       it++)
    std::cout << *(it) + 1 << " ";
  for (int i = couples[num][1] + 1; i < n; i++) std::cout << i + 1 << " ";
  return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me? 

— Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night? 

At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcoming walk. He needed to cut down several trees.

Let's consider the woodland belt as a sequence of trees. Each tree i is described by the esthetic appeal ai — some trees are very esthetically pleasing, others are 'so-so', and some trees are positively ugly!

The Smart Beaver calculated that he needed the following effects to win the Beaverette's heart: 

  * The first objective is to please the Beaverette: the sum of esthetic appeal of the remaining trees must be maximum possible; 
  * the second objective is to surprise the Beaverette: the esthetic appeal of the first and the last trees in the resulting belt must be the same; 
  * and of course, the walk should be successful: there must be at least two trees in the woodland belt left. 



Now help the Smart Beaver! Which trees does he need to cut down to win the Beaverette's heart?

Input

The first line contains a single integer n — the initial number of trees in the woodland belt, 2 ≤ n. The second line contains space-separated integers ai — the esthetic appeals of each tree. All esthetic appeals do not exceed 109 in their absolute value.

  * to get 30 points, you need to solve the problem with constraints: n ≤ 100 (subproblem A1); 
  * to get 100 points, you need to solve the problem with constraints: n ≤ 3·105 (subproblems A1+A2). 

Output

In the first line print two integers — the total esthetic appeal of the woodland belt after the Smart Beaver's intervention and the number of the cut down trees k.

In the next line print k integers — the numbers of the trees the Beaver needs to cut down. Assume that the trees are numbered from 1 to n from left to right.

If there are multiple solutions, print any of them. It is guaranteed that at least two trees have equal esthetic appeal.

Examples

Input

5
1 2 3 1 2


Output

8 1
1 

Input

5
1 -2 3 1 -2


Output

5 2
2 5 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void qSort(long long **a, int first, int last) {
  long long i = first, j = last, x = a[(first + last) / 2][0];
  do {
    while (a[i][0] < x) i++;
    while (a[j][0] > x) j--;
    if (i <= j) {
      if (i < j) {
        long long tmp0, tmp1;
        tmp0 = a[i][0];
        tmp1 = a[i][1];
        a[i][0] = a[j][0];
        a[i][1] = a[j][1];
        a[j][0] = tmp0;
        a[j][1] = tmp1;
      }
      i++;
      j--;
    }
  } while (i <= j);
  if (i < last) qSort(a, i, last);
  if (first < j) qSort(a, first, j);
}
void build(long long *t, long long *a, int v, int tl, int tr) {
  if (tl == tr)
    t[v] = max(a[tl], (long long)0);
  else {
    int tm = (tl + tr) / 2;
    build(t, a, v * 2, tl, tm);
    build(t, a, v * 2 + 1, tm + 1, tr);
    t[v] = max(t[v * 2], (long long)0) + max(t[v * 2 + 1], (long long)0);
  }
}
long long sum(long long *t, int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (l == tl && r == tr) return t[v];
  int tm = (tl + tr) / 2;
  return sum(t, v * 2, tl, tm, l, min(r, tm)) +
         sum(t, v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}
int main() {
  int n;
  std::cin >> n;
  long long *t = new long long[4 * n];
  long long *forest = new long long[n];
  long long **_forest = new long long *[n];
  for (int i = 0; i < n; i++) _forest[i] = new long long[2];
  long long tmp;
  for (int i = 0; i < n; i++) {
    std::cin >> tmp;
    forest[i] = tmp;
    _forest[i][0] = tmp;
    _forest[i][1] = i;
  }
  qSort(_forest, 0, n - 1);
  build(t, forest, 1, 0, n - 1);
  long long **couples = new long long *[(n / 2) + 1];
  for (int i = 0; i < n / 2 + 1; i++) couples[i] = new long long[2];
  int couple_count = 0;
  long long now = -1000000000000000000;
  int i = 0;
  while (i < n) {
    now = _forest[i][0];
    int min = n, max = 0;
    while (i < n && _forest[i][0] == now) {
      if (_forest[i][1] < min) min = _forest[i][1];
      if (_forest[i][1] > max) max = _forest[i][1];
      i++;
    }
    if (min != max && max != 0) {
      couples[couple_count][0] = min;
      couples[couple_count][1] = max;
      couple_count++;
    }
  }
  long long max = -100000000000000000;
  int num = 0;
  for (int i = 0; i < couple_count; i++) {
    long long su = 0;
    su += sum(t, 1, 0, n - 1, couples[i][0] + 1, couples[i][1] - 1);
    su = su + forest[couples[i][0]] + forest[couples[i][1]];
    if (su > max) {
      max = su;
      num = i;
    }
  }
  std::vector<int> toDelete;
  int del = 0;
  del = del + couples[num][0] + (n - 1 - couples[num][1]);
  for (int i = couples[num][0] + 1; i < couples[num][1]; i++)
    if (forest[i] < 0) {
      del++;
      toDelete.push_back(i);
    }
  std::cout << max << " " << del << std::endl;
  for (int i = 0; i < couples[num][0]; i++) std::cout << i + 1 << " ";
  for (std::vector<int>::iterator it = toDelete.begin(); it != toDelete.end();
       it++)
    std::cout << *(it) + 1 << " ";
  for (int i = couples[num][1] + 1; i < n; i++) std::cout << i + 1 << " ";
  return 0;
}

```