package org.wangyi; import java.util.*; public class Test01 {     public static void main(String[] args) {         Scanner sc=new Scanner(System.in);         int n=sc.nextInt();         int[] jump=new int[n];         for(int i=0;i<n;i++){             jump[i]=sc.nextInt();         }         int res=bfs(jump);         System.out.println(res);     }     public static int bfs(int[] jump){         Queue<Integer> queue=new LinkedList<>();         queue.offer(0);         int cnt=0;         while (!queue.isEmpty()) {             int size=queue.size();             for(int k=0;k<size;k++){                 Integer node = queue.poll();                 if(node>=jump.length){                     return cnt;                 }                 for(int i=0;i<node;i++){                     queue.offer(i);                 }                 queue.offer(node+jump[node]);             }             cnt++;         }         return cnt;     } }