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



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]

