Yuuka has a deck of n cards labeled with 0,1,2,…,(n−1).
Initially, the cards are placed in the order p_1,p_2,…,p_n from top to bottom. In each round, if the top card is labeled with x, Yuuka will place it x cards downward, so it becomes the card number (x+1) in the deck, counting from 1. The relative order of other cards will not be changed.
How many rounds will pass until the card labeled with 0 comes to the top?
The first line contains an integer n (1≤n≤32).
The second line contains n distinct integers p_1,p_2,…,p_n (0≤p_i<n).
Output an integer which denotes the number of rounds. If the card labeled with 0 never comes to the top, output "-1" instead.