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 Ai be the number written on cell i. From cell i, Jaehwan can jump in one move to a cell at most Ai 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.
The first line contains N (1≤N≤1000).
The second line contains A1,A2,…,AN separated by spaces (0≤Ai≤100).
Print the minimum number of jumps needed to reach the rightmost cell on one line. If the rightmost cell cannot be reached, print -1.