{"problem":{"name":"Ameba","description":{"content":"You observed amoebae and kept some records. Initially, there was one amoeba, numbered $1$. You made $N$ records. According to the $i$\\-th record, the amoeba numbered $A_i$ disappeared by dividing itse","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc274_c"},"statements":[{"statement_type":"Markdown","content":"You observed amoebae and kept some records.\nInitially, there was one amoeba, numbered $1$.\nYou made $N$ records. According to the $i$\\-th record, the amoeba numbered $A_i$ disappeared by dividing itself into two new amoebae, which were then numbered $2i$ and $2i+1$.  \nHere, amoeba $A_i$ is said to be the parent of amoebae $2i$ and $2i+1$.\nFor each $k=1,\\ldots,2N+1$, how many generations away is amoeba $k$ from amoeba $1$?\n\n## Constraints\n\n*   $1 \\leq N \\leq 2\\times 10^5$\n*   The records are consistent. That is:\n    *   $1\\leq A_i \\leq 2i-1$.\n    *   $A_i$ are distinct integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\ldots$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc274_c","tags":[],"sample_group":[["2\n1 2","0\n1\n1\n2\n2\n\nFrom amoeba $1$, amoebae $2$ and $3$ were born. From amoeba $2$, amoebae $4$ and $5$ were born.\n\n*   Amoeba $1$ is zero generations away from amoeba $1$.\n*   Amoeba $2$ is one generation away from amoeba $1$.\n*   Amoeba $3$ is one generation away from amoeba $1$.\n*   Amoeba $4$ is one generation away from amoeba $2$, and two generations away from amoeba $1$.\n*   Amoeba $5$ is one generation away from amoeba $2$, and two generations away from amoeba $1$."],["4\n1 3 5 2","0\n1\n1\n2\n2\n3\n3\n2\n2"]],"created_at":"2026-03-03 11:01:14"}}