MNYC '17: 2048View as PDF
Gabriel is playing 2048. In this game, squares appear with a number on it. All the numbers are positive powers of 2. You can combine two of the same power to get one power greater. For example, if you combine two s you get a square. Gabriel has squares and wants to know the biggest square he can obtain from combining.
A single integer, , the number of squares.
The second line contains integers, , the number on the squares.
A single integer, the biggest square can Gabriel can theoretically create.
Sample Input 1
3 2 4 2
Sample Output 1
Explanation for Sample Output 1
Gabriel can combine the two s to make a and then he can combine the two s he has to make an .
Sample Input 2
5 2 2 8 16 32
Sample Output 2
Explanation for Sample Output 2
Although Gabriel can combine the two s, he cannot make any more moves. The biggest square he has is .