Under construction

Still being built. Things may change

Best Solution Unknown

Time limit3sMemory limit512 MB

Summary
Each match removes one of two adjacent players, and the stronger one wins and gains 1 strength. List every index that can end as the sole winner.
Level

Hard8 of 10

Topics
Stack, Greedy, Binary search
Solved
No attempts yet

Statement

You are the responsible holder of a competition called Best Solution Unknown (BSU). The rules of this competition are simple but rather quirky.

First, all the nn participants stand in a row. Then, n−1n-1 matches are held. In each match, the jury chooses two adjacent players. The chosen players are given an NP-hard problem, and they try their best to come up with a good solution. The one who provides a better solution wins a round, and the other one leaves the competition. After that, the players shift to form a valid row again, so the player adjacent to the player who left becomes adjacent to the winner. After all n−1n-1 matches, only one player remains, and this player is declared the winner of the competition.

The strength of the ii-th player, counting from the left, is aia_i. You know the strength of each player before the competition. A player with greater strength wins the match. If the strengths are equal, either player may win. The strength of the winner of a match increases by one.

You do not know who plays in each match, or who wins a match when the strengths are equal. Find every participant who can become the winner of the competition.

Input

The first line contains nn (1≤n≤1061 \le n \le 10^6), the number of participants. The second line contains nn integers aia_i (1≤ai≤1091 \le a_i \le 10^9), the initial strength of the ii-th participant.

Output

The first line should contain kk (1≤k≤n1 \le k \le n), the number of participants that can possibly win. The second line should contain kk integers bib_i in strictly increasing order, the indices of these participants (1≤b1<b2<…<bk≤n1 \le b_1 < b_2 < \ldots < b_k \le n).

Examples4

  1. Example 1

    Input
    3
    3 2 2
    
    Expected output
    3
    1 2 3
    
  2. Example 2

    Input
    3
    1 2 1
    
    Expected output
    1
    2
    
  3. Example 3

    Input
    5
    1 2 3 5 5
    
    Expected output
    3
    3 4 5
    
  4. Example 4

    Input
    1
    10
    
    Expected output
    1
    1