import java.util.ArrayDeque; import java.util.Queue; import java.util.Scanner; class Main { int n; Queue q; int[] move; int[] step; public static void main(String[] args){ Scanner sc = new Scanner(System.in); Main m = new Main(sc); m.solve(); } Main(Scanner sc){ n = sc.nextInt(); q = new ArrayDeque(); move = new int[n]; step = new int[n]; for(int i = 0;i0){ i = q.remove(); if(i >= 0 && i < n){ if(i-move[i] >= 0 && i - move[i] < n){ if(step[i-move[i]]==-1){ q.add(i-move[i]); step[i-move[i]] = step[i] + 1; } } if(i+move[i] >= 0 && i + move[i] < n){ if(step[i+move[i]]==-1){ q.add(i+move[i]); step[i+move[i]] = step[i] + 1; } } } } System.out.println(step[n-1]); } }