import sys
from collections import deque
input = sys.stdin.readline
n = int(input())
nums = list(map(int, input().split()))
visited = [0]*n
q = deque()
q.append((0, 0)) # (index, jump_time)
visited[0] = 1
while q:
idx, t = q.popleft()
if idx == n-1:
print(t)
exit(0)
for i in range(1, nums[idx]+1):
if (idx+i) < n and not visited[idx+i]:
visited[idx+i] = 1
q.append((idx+i, t+1))
print(-1)