n = gets.to_i
p = n.times.map{gets.to_i}
dp = Array.new(n,Float::INFINITY)
dp[0] = 0
visited = Array.new(n,false)
n.times do |i|
    next if dp[i] == Float::INFINITY
    1.upto(6) do |d|
        break if i + d >= n
        if p[i+d] == 0
            dp[i+d] = dp[i] + 1 if dp[i] + 1 < dp[i+d]
            visited[i+d] = true
        else
            nd = i + d
            l = false
            while p[nd] != 0
                if visited[nd]
                    l = true
                    break
                end
                visited[nd] = true
                nd += p[nd]
            end
            dp[nd] = dp[i] + 1 if dp[i] + 1 < dp[nd] && !l
            visited[nd] = true
        end
    end
end
p dp[n-1]