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

move = [nil]*(N+6)


(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] == false || move[ptr] < 0
        stack.each do |j|
            move[j] = false
        end
    else
        t = move[ptr]
        stack.each do |j|
            move[j] = t
        end
    end
end


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

queue = [[0,0]]

while !queue.empty?
    i,step = queue.shift
    1.upto(6) do |hop|
        to = move[i+hop]
        if to && step+1 < dp[to]
            dp[to] = step+1
            queue.push([to, step+1])
            if to == N-1
                queue = []
                break
            end
        end
    end
end


p dp[N-1]

