{"problem":{"name":"Kode Festival","description":{"content":"_Kode Festival_ is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for \"hardness\".) This year, $2^N$ stones participated. The hardness of the $i$\\-th ston","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"relay_c"},"statements":[{"statement_type":"Markdown","content":"_Kode Festival_ is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for \"hardness\".)\nThis year, $2^N$ stones participated. The hardness of the $i$\\-th stone is $A_i$.\nIn the contest, stones are thrown at each other in a knockout tournament.\nWhen two stones with hardness $X$ and $Y$ are thrown at each other, the following will happen:\n\n*   When $X$ > $Y$: The stone with hardness $Y$ will be destroyed and eliminated. The hardness of the stone with hardness $X$ will become $X-Y$.\n    \n*   When $X$ = $Y$: One of the stones will be destroyed and eliminated. The hardness of the other stone will remain the same.\n    \n*   When $X$ < $Y$: The stone with hardness $X$ will be destroyed and eliminated. The hardness of the stone with hardness $Y$ will become $Y-X$.\n    \n\nThe $2^N$ stones will fight in a knockout tournament as follows:\n\n1.  The following pairs will fight: (the $1$\\-st stone versus the $2$\\-nd stone), (the $3$\\-rd stone versus the $4$\\-th stone), ...\n    \n2.  The following pairs will fight: (the winner of ($1$\\-st versus $2$\\-nd) versus the winner of ($3$\\-rd versus $4$\\-th)), (the winner of ($5$\\-th versus $6$\\-th) versus the winner of ($7$\\-th versus $8$\\-th)), ...\n    \n3.  And so forth, until there is only one stone remaining.\n    \n\nDetermine the eventual hardness of the last stone remaining.\n\n## Constraints\n\n*   $1 \\leq N \\leq 18$\n*   $1 \\leq A_i \\leq 10^9$\n*   $A_i$ is an integer.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$A_1$\n$A_2$\n:\n$A_{2^N}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"relay_c","tags":[],"sample_group":[["2\n1\n3\n10\n19","7"],["3\n1\n3\n2\n4\n6\n8\n100\n104","2"]],"created_at":"2026-03-03 11:01:13"}}