시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 512 MB 0 0 0 0.000%

## 문제

Yuuka has a deck of $n$ cards labeled with $0, 1, 2, \dots, (n - 1)$.

Initially, the cards are placed in the order $p_1, p_2, \dots, 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 \leq n \leq 32$).

The second line contains $n$ distinct integers $p_1, p_2, \dots, p_n$ ($0 \leq 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.

## 예제 입력 1

5
1 3 2 4 0


## 예제 출력 1

13


## 예제 입력 2

2
0 1


## 예제 출력 2

0
{"ft_lang_label":"__label__en","ft_lang_prob":0.8666595,"math_prob":0.99827176,"size":822,"snap":"2020-24-2020-29","text_gpt3_token_len":294,"char_repetition_ratio":0.123471886,"word_repetition_ratio":0.011976048,"special_character_ratio":0.36982968,"punctuation_ratio":0.13402061,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9849885,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-07-06T22:27:21Z\",\"WARC-Record-ID\":\"<urn:uuid:7095b20e-3c4c-49bb-898b-cdcc462b39e6>\",\"Content-Length\":\"28187\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:aa8bed99-093f-4dd7-a61a-e1a2674039d0>\",\"WARC-Concurrent-To\":\"<urn:uuid:8c82fa63-fe4e-487a-920c-cd261ccef7d5>\",\"WARC-IP-Address\":\"3.113.117.161\",\"WARC-Target-URI\":\"https://www.acmicpc.net/problem/19398\",\"WARC-Payload-Digest\":\"sha1:FHL7V5GLJRNKHXMBCT6OOUTOV6CQZOJO\",\"WARC-Block-Digest\":\"sha1:H5YKJMJXCAVBEIB7KFFQTHEUMRPE4N5J\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-29/CC-MAIN-2020-29_segments_1593655890566.2_warc_CC-MAIN-20200706222442-20200707012442-00459.warc.gz\"}"}