{"problem":{"name":"Spices","description":{"content":"The shop supaisu-ya sells $2^N-1$ kinds of spices: Spice $1$, Spice $2$, $\\ldots$, Spice $2^N-1$. One pack of each spice is in stock. For each $i = 1, 2, \\ldots, 2^N-1$, Spice $i$ costs $c_i$ yen. Tak","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc236_f"},"statements":[{"statement_type":"Markdown","content":"The shop supaisu-ya sells $2^N-1$ kinds of spices: Spice $1$, Spice $2$, $\\ldots$, Spice $2^N-1$. One pack of each spice is in stock. For each $i = 1, 2, \\ldots, 2^N-1$, Spice $i$ costs $c_i$ yen. Takahashi can buy any of these spices.\nHe plans to make curry after getting home by choosing one or more of the bought spices and mixing them.  \nIf $k$ spices, Spice $A_1$, Spice $A_2$, $\\ldots$, Spice $A_k$, are mixed, the hotness of the resulting curry is $A_1 \\oplus A_2 \\oplus \\cdots \\oplus A_k$, where $\\oplus$ denotes the bitwise XOR.\nTakahashi wants to decide the hotness of the curry based on his feeling after getting home. For now, he will buy a set of spices that allows him to make curry of any hotness from $1$ through $2^N-1$. Print the minimum possible amount of money Takahashi pays.\n\n## Constraints\n\n*   $2 \\leq N \\leq 16$\n*   $1 \\leq c_i \\leq 10^9$\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$c_1$ $c_2$ $\\ldots$ $c_{2^N-1}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc236_f","tags":[],"sample_group":[["2\n4 5 3","7\n\nIf Takahashi buys Spice $1$ and $3$, he can make curry of any hotness from $1$ through $3$, as follows.\n\n*   To make curry of hotness $1$, use just Spice $1$.\n*   To make curry of hotness $2$, mix Spice $1$ and Spice $3$.\n*   To make curry of hotness $3$, use just Spice $3$.\n\nHere, Takahashi pays $c_1 + c_3 = 4 + 3 = 7$ yen, which is the minimum possible amount he pays."],["4\n9 7 9 7 10 4 3 9 4 8 10 5 6 3 8","15"]],"created_at":"2026-03-03 11:01:14"}}