Jump Jump

No attempts yetTime limit1sMemory limit256 MB

Problem

Jaehwan is trapped in a maze of size 1×N. The maze is a single row of N cells of size 1×1, and each cell holds one integer. Let AiA_i be the number written on cell i. From cell i, Jaehwan can jump in one move to a cell at most AiA_i positions to the right. For example, if cell 3 holds the number 3, he can jump to cell 4, cell 5, or cell 6.

Jaehwan stands on the leftmost cell and wants to reach the rightmost cell. Write a program that finds the smallest number of jumps he needs. If he cannot reach the rightmost cell, print -1.

Input

The first line contains N (1N10001 \le N \le 1000).

The second line contains A1,A2,,ANA_1, A_2, \dots, A_N separated by spaces (0Ai1000 \le A_i \le 100).

Output

Print the minimum number of jumps needed to reach the rightmost cell on one line. If the rightmost cell cannot be reached, print -1.