JOI found a sugoroku board at his uncle's house. The board is a line of N+2 squares. Square 1 is the start and square N+2 is the goal. Every other square has either 0 or 1 written on it, and for each i (1≤i≤N) the number written on square i+1 is Ai.
The game begins with the piece on the start square. After that, you repeat one action: roll the die and move the piece forward by the number rolled. If the piece stops on a square with 1 written on it, the game is over. If the piece never stops on a square with 1 and it either stops exactly on the goal square or moves past the goal square, the game is cleared.
JOI went to a toy shop to buy a die for the game. The shop sells N+1 dice. Die j (1≤j≤N+1) has j faces, with 1,2,…,j written one per face.
Among the dice for which some sequence of rolls clears the game, JOI buys the one with the fewest faces. Which die should he buy?