Problem Description

Read n integers where a[i] is max jump length from i. Output minimum jumps from 0 to n-1 or -1 if not possible.

Input Format

First line n. Second line n integers.

Output Format

One integer minJumps.

Sample Test Case

Input:
6 2 3 1 1 4 0
Output:
3

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next