#ABC274C. [ABC274C] Ameba

[ABC274C] Ameba

Score : 300300 points

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,,2N+1k=1,\ldots,2N+1, how many generations away is amoeba kk from amoeba 11?

Constraints

  • 1N2×1051 \leq N \leq 2\times 10^5
  • The records are consistent. That is:- 1Ai2i11\leq A_i \leq 2i-1.
    • AiA_i are distinct integers.
  • 1Ai2i11\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 ANA_N

Output

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

2
1 2
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.
4
1 3 5 2
0
1
1
2
2
3
3
2
2