{"problem":{"name":"Strange Balls","description":{"content":"Takahashi has $N$ balls. Each ball has an integer not less than $2$ written on it. He will insert them in a cylinder one by one. The integer written on the $i$\\-th ball is $a_i$. The balls are made of","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc240_d"},"statements":[{"statement_type":"Markdown","content":"Takahashi has $N$ balls. Each ball has an integer not less than $2$ written on it. He will insert them in a cylinder one by one. The integer written on the $i$\\-th ball is $a_i$.\nThe balls are made of special material. When $k$ balls with $k$ $(k \\geq 2)$ written on them line up in a row, all these $k$ balls will disappear.\nFor each $i$ $(1 \\leq i \\leq N)$, find the number of balls after inserting the $i$\\-th ball.\n\n## Constraints\n\n*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $2 \\leq a_i \\leq 2 \\times 10^5 \\, (1 \\leq i \\leq N)$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$a_1$ $\\ldots$ $a_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc240_d","tags":[],"sample_group":[["5\n3 2 3 2 2","1\n2\n3\n4\n3\n\nThe content of the cylinder changes as follows.\n\n*   After inserting the $1$\\-st ball, the cylinder contains the ball with $3$.\n*   After inserting the $2$\\-nd ball, the cylinder contains $3, 2$ from bottom to top.\n*   After inserting the $3$\\-rd ball, the cylinder contains $3, 2, 3$ from bottom to top.\n*   After inserting the $4$\\-th ball, the cylinder contains $3, 2, 3, 2$ from bottom to top.\n*   After inserting the $5$\\-th ball, the cylinder momentarily has $3, 2, 3, 2, 2$ from bottom to top. The two consecutive balls with $2$ disappear, and the cylinder eventually contains $3, 2, 3$ from bottom to top.\n\n![image](https://img.atcoder.jp/ghi/ABC240D_sample.png)"],["10\n2 3 2 3 3 3 2 3 3 2","1\n2\n3\n4\n5\n3\n2\n3\n1\n0"]],"created_at":"2026-03-03 11:01:13"}}