http://codeforces.com/contest/500/problem/A
1 import java.util.Scanner; 2 3 public class Main { 4 static final int MAX = Integer.MAX_VALUE; 5 6 public static void main(String[] args) { 7 Scanner io = new Scanner(System.in); 8 int n = io.nextInt(), t = io.nextInt(); 9 int[] a = new int[n + 1]; 10 for (int i = 1; i <= n-1; i++) a[i] = io.nextInt(); 11 int x=1; 12 while (x<t){ 13 x+=a[x]; 14 if (x==t) { System.out.println("YES");return; } 15 } 16 System.out.println("NO"); 17 } 18 19 20 }