410298: GYM104003 F William and Cards

Memory Limit:256 MB Time Limit:7 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. William and Cardstime limit per test7.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

William likes to play card games. In this particular game, William is dealt a row of $$$N$$$ playing cards. Each of the cards has a positive integer point value, where the $$$i$$$-th card in the row has a point value of $$$p_i$$$.

The object of the card game is to minimize the maximum point value among all of the cards that William has. To do so, William is allowed to perform operations. For any $$$1 \leq i < N$$$, William may halve $$$p_i$$$ and double $$$p_{i-1}$$$ so long as $$$p_i$$$ is an even number. William may perform as many operations as he desires.

If William performs operations optimally, can you figure out the minimum maximum point value that he can achieve?

Input

The input will begin with a line containing a single integer $$$N\ (1 \leq N \leq 10^5)$$$. The next line will contain $$$N$$$ space-separated integers $$$p_0, \dots, p_{N-1}\ (1 \leq p_i \leq 10^9)$$$, the initial point values of the $$$N$$$ playing cards that William is dealt.

Output

The output should consist of a single integer representing the minimum maximum point value among all of the cards William is dealt assuming that he performs optimal operations.

ExampleInput
5
1 25 36 80 12
Output
25

加入题单

上一题 下一题 算法标签: