package yukicoder; import java.util.Scanner; public class N504 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int N=sc.nextInt(); long a[]=new long[N]; int ans[]=new int[N]; a[0]=sc.nextLong(); ans[0]=1; for(int i=1;i=a[i])?(ans[i-1]):(ans[i-1]+1); } for(int i:ans) { System.out.println(i); } } }