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)

cur = 0
adj = [cur]
while !adj.empty?
    cur = adj.shift
    break if cur == n - 1
    1.upto(6) do |d|
        break if cur + d >= n
        next if visited[cur+d]
        if p[cur+d] == 0
            adj.push(cur+d)
            dp[cur+d] = dp[cur] + 1 if dp[cur] + 1 < dp[cur+d]
            visited[cur+d] = true
        else
            nd = cur + d
            l = false
            while p[nd] != 0
                if visited[nd]
                    l = true
                    break
                end
                visited[nd] = true
                nd += p[nd]
            end
            if !visited[nd]
                adj.push(nd)
                dp[nd] = dp[cur] + 1 if dp[cur] + 1 < dp[nd]
                visited[nd] = true
            end
        end
    end
end
p dp[n-1]