The author intended to create a legend for this problem, but the calculus colloquium demanded more of their attention.
You are provided with the correct prefix function of a specific string. Your task is to compute the z-function for this same string.
The first line of the input contains the integer (1 \leq N \leq 10^6). The following line contains non-negative integers, which represent the prefix function.
Output a single line containing non-negative integers, which represent the z-function.
مثال 1