题目描述
Problem Description
JOI-kun found a sugoroku board at his uncle's house. The sugoroku board consists of $ N+2 $ squares arranged in a straight line, with the $ 1 $st square being the start and the $ N+2 $nd square being the goal. Each of the other squares contains either $ 0 $ or $ 1 $, and for each $ i $ ($1 \leq i \leq N$), the number written on the $ i+1 $th square is $ A_i $.
In sugoroku, you initially place a piece on the start square and repeatedly roll a die to move the piece forward by the number of spaces shown on the die. However, if the piece lands on a square with a $ 1 $, the game is over. If you can stop on the goal square or pass it without landing on a $ 1 $, you clear the game.
JOI-kun decided to go to the toy store to buy a die to play the sugoroku. The toy store sells $ N+1 $ dice. The $ j $th die ($1 \leq j \leq N+1$) has $ j $ faces, each showing numbers $ 1, 2, ..., j $.
JOI-kun decided to buy the die with the fewest faces that allows him to clear the game. Which die should JOI-kun buy?
Input Format
The input is given from the standard input in the following format:
$ N $ $ A_1 $ $ A_2 $ ... $ A_N $
Output Format
Output the number of faces of the die that JOI-kun should purchase.
Sample Input and Output
Sample Input #1
5
0 1 0 0 0
Sample Output #1
2
Sample Input #2
5
1 1 1 1 1
Sample Output #2
6
Sample Input #3
7
0 0 1 0 1 1 0
Sample Output #3
3
Notes/Hints
Constraints
- $1 \leq N \leq 100$
- $0 \leq A_i \leq 1$ ($1 \leq i \leq N$)
Sample Explanation 1
The sugoroku consists of $ 7 $ squares, with only the $ 3 $rd square containing a $ 1 $. If you use a die with $ 2 $ faces, for example, if the rolls are $ 1, 2, 1, 1, 1 $, you can clear the game. This is the minimum, so output $ 2 $.
Sample Explanation 2
The sugoroku consists of $ 7 $ squares, with all squares except the start and goal containing a $ 1 $. In this case, a die with $ 6 $ faces is necessary. This is the minimum, so output $ 6 $.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分