Binary Search Game

Determine whether a player can always guess x within a_x comparison questions given a monotone budget array, and list all valid first questions q.

Hard8Binary searchGreedyDynamic programmingNo attempts yetTime limit2sMemory limit64 MB

Problem

Jihak built the following game to teach binary search.

  1. The computer picks an integer xx at random with 1xn1 \le x \le n and tells the player the value of nn.
  2. The player picks an integer qq and asks "Is xx at most qq?". The computer answers yes or no. The player may ask this question as often as they want, and there is no restriction on the integer qq.
  3. Once the player decides that xx is known, the player names a guess vv and asks "Is xx equal to vv?" one time. The computer prints the verdict and the game ends.

Students were learning binary search from this game until Jaehyun told them the optimal strategy in advance, which made the game too easy. Jihak then changed the rule. The computer prints success only when v=xv = x and the number of "Is xx at most qq?" questions asked so far is at most axa_x, and prints failure otherwise. The final confirmation question is not counted. Jihak likes sorted sequences, so the sequence aa satisfies a1a2ana_1 \le a_2 \le \cdots \le a_n.

Jaehyun could not find a way to always succeed in the changed game and claimed that no such way exists. Jihak could not prove otherwise and asked you for help.

Decide whether there is a way of asking that always succeeds no matter which xx the computer picked, and if there is, find every qq that may be asked as the first question. A value qq may be asked as the first question when there is a way to start with "Is xx at most qq?", then choose every later question from the answers received, and succeed for every xx.

Input

The first line contains nn (1n1061 \le n \le 10^6).

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1a1a2an1091 \le a_1 \le a_2 \le \cdots \le a_n \le 10^9) separated by spaces.

Output

On the first line, print how many values of qq may be asked as the first question. If infinitely many such qq exist, print inf instead of a count.

On the second line, print those values of qq in increasing order, separated by spaces. If no such qq exists, or if infinitely many exist, print nothing on the second line.