N = gets.to_i
P = N.times.map{gets.to_i} + [0]*6

move = [nil]*(N+6)

# dfs1 = lambda do |i|
#     if move[i] == -1
#         move[i] = false
#         next false
#     end
#     next move[i] = move[i] if move[i] != nil
#     next move[i] = i       if P[i] == 0
#     move[i] = -1
#     res = dfs1.call(i+P[i])
#     next move[i] = res     if res
#     next move[i] = false
# end
# 
# (N+6).times do |i|
#     dfs1.call(i)
# end

(N+6).times do |i|
    ptr = i
    stack = []
    while move[ptr] == nil
        if P[ptr] == 0
            move[ptr] = ptr
            break
        end
        move[ptr] = -1
        stack << ptr
        ptr = ptr + P[ptr]
    end
    if move[ptr] == -1 || move[ptr] == false
        stack.each do |j|
            move[j] = false
        end
    else
        stack.reverse_each do |j|
            move[j] = move[ptr]
            ptr = j
        end
    end
end


dp = [10101010]*(N+6)
dp[0] = 0

(N-1).times do |ptr|
    1.upto(6) do |hop|
        to = move[ptr+hop]
        dp[to] = [dp[to], dp[ptr]+1].min if to
    end
end

p dp[N-1]

