#abc274c. [abc274_c]Ameba

[abc274_c]Ameba

Problem Statement

You observed amoebae and kept some records.

Initially, there was one amoeba, numbered 11.

You made NN records. According to the ii-th record, the amoeba numbered AiA_i disappeared by dividing itself into two new amoebae, which were then numbered 2i2i and 2i+12i+1.
Here, amoeba AiA_i is said to be the parent of amoebae 2i2i and 2i+12i+1.

For each k=1,ldots,2N+1k=1,\\ldots,2N+1, how many generations away is amoeba kk from amoeba 11?

Constraints

  • 1leqNleq2times1051 \\leq N \\leq 2\\times 10^5
  • The records are consistent. That is:
    • 1leqAileq2i11\\leq A_i \\leq 2i-1.
    • AiA_i are distinct integers.

Input

The input is given from Standard Input in the following format:

NN A1A_1 A2A_2 ldots\\ldots ANA_N

Output

Print 2N+12N+1 lines. The kk-th line should contain the generation distance between amoeba 11 and amoeba kk.


Sample Input 1

2
1 2

Sample Output 1

0
1
1
2
2

From amoeba 11, amoebae 22 and 33 were born. From amoeba 22, amoebae 44 and 55 were born.

  • Amoeba 11 is zero generations away from amoeba 11.
  • Amoeba 22 is one generation away from amoeba 11.
  • Amoeba 33 is one generation away from amoeba 11.
  • Amoeba 44 is one generation away from amoeba 22, and two generations away from amoeba 11.
  • Amoeba 55 is one generation away from amoeba 22, and two generations away from amoeba 11.

Sample Input 2

4
1 3 5 2

Sample Output 2

0
1
1
2
2
3
3
2
2