atcoder#ABC236F. [ABC236F] Spices
[ABC236F] Spices
Score : points
Problem Statement
The shop supaisu-ya sells kinds of spices: Spice , Spice , , Spice . One pack of each spice is in stock. For each , Spice costs yen. Takahashi can buy any of these spices.
He plans to make curry after getting home by choosing one or more of the bought spices and mixing them. If spices, Spice , Spice , , Spice , are mixed, the hotness of the resulting curry is , where denotes the bitwise XOR.
Takahashi 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 through . Print the minimum possible amount of money Takahashi pays.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the minimum possible amount of money Takahashi pays.
2
4 5 3
7
If Takahashi buys Spice and , he can make curry of any hotness from through , as follows.
- To make curry of hotness , use just Spice .
- To make curry of hotness , mix Spice and Spice .
- To make curry of hotness , use just Spice .
Here, Takahashi pays yen, which is the minimum possible amount he pays.
4
9 7 9 7 10 4 3 9 4 8 10 5 6 3 8
15