{"raw_statement":[{"iden":"problem statement","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."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 18$\n*   $1 \\leq A_i \\leq 10^9$\n*   $A_i$ is an integer."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$A_1$\n$A_2$\n:\n$A_{2^N}$"},{"iden":"sample input 1","content":"2\n1\n3\n10\n19"},{"iden":"sample output 1","content":"7"},{"iden":"sample input 2","content":"3\n1\n3\n2\n4\n6\n8\n100\n104"},{"iden":"sample output 2","content":"2"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}