{"problem":{"name":"Merge the balls","description":{"content":"You have an empty sequence and $N$ balls. The size of the $i$\\-th ball $(1 \\leq i \\leq N)$ is $2^{A_i}$. You will perform $N$ operations.   In the $i$\\-th operation, you add the $i$\\-th ball to the ri","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc351_c"},"statements":[{"statement_type":"Markdown","content":"You have an empty sequence and $N$ balls. The size of the $i$\\-th ball $(1 \\leq i \\leq N)$ is $2^{A_i}$.\nYou will perform $N$ operations.  \nIn the $i$\\-th operation, you add the $i$\\-th ball to the right end of the sequence, and repeat the following steps:\n\n1.  If the sequence has one or fewer balls, end the operation.\n2.  If the rightmost ball and the second rightmost ball in the sequence have **different** sizes, end the operation.\n3.  If the rightmost ball and the second rightmost ball in the sequence have the **same** size, remove these two balls and add a new ball to the right end of the sequence with a size equal to the sum of the sizes of the two removed balls. Then, go back to step 1 and repeat the process.\n\nDetermine the number of balls remaining in the sequence after the $N$ operations.\n\n## Constraints\n\n*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $0 \\leq A_i \\leq 10^9$\n*   All input values are 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":"abc351_c","tags":[],"sample_group":[["7\n2 1 1 3 5 3 3","3\n\nThe operations proceed as follows:\n\n*   After the first operation, the sequence has one ball, of size $2^2$.\n*   After the second operation, the sequence has two balls, of sizes $2^2$ and $2^1$ in order.\n*   After the third operation, the sequence has one ball, of size $2^3$. This is obtained as follows:\n    *   When the third ball is added during the third operation, the sequence has balls of sizes $2^2, 2^1, 2^1$ in order.\n    *   The first and second balls from the right have the same size, so these balls are removed, and a ball of size $2^1 + 2^1 = 2^2$ is added. Now, the sequence has balls of sizes $2^2, 2^2$.\n    *   Again, the first and second balls from the right have the same size, so these balls are removed, and a ball of size $2^2 + 2^2 = 2^3$ is added, leaving the sequence with a ball of size $2^3$.\n*   After the fourth operation, the sequence has one ball, of size $2^4$.\n*   After the fifth operation, the sequence has two balls, of sizes $2^4$ and $2^5$ in order.\n*   After the sixth operation, the sequence has three balls, of sizes $2^4$, $2^5$, $2^3$ in order.\n*   After the seventh operation, the sequence has three balls, of sizes $2^4$, $2^5$, $2^4$ in order.\n\nTherefore, you should print $3$, the final number of balls in the sequence."],["5\n0 0 0 1 2","4\n\nThe operations proceed as follows:\n\n*   After the first operation, the sequence has one ball, of size $2^0$.\n*   After the second operation, the sequence has one ball, of size $2^1$.\n*   After the third operation, the sequence has two balls, of sizes $2^1$ and $2^0$ in order.\n*   After the fourth operation, the sequence has three balls, of sizes $2^1$, $2^0$, $2^1$ in order.\n*   After the fifth operation, the sequence has four balls, of sizes $2^1$, $2^0$, $2^1$, $2^2$ in order.\n\nTherefore, you should print $4$, the final number of balls in the sequence."]],"created_at":"2026-03-03 11:01:13"}}