|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||128 MB||0||0||0||0.000%|
The best selling vegetable in Byteland is logarithmic paprika. As the name of this great vegetable suggests, the weight of each paprika is the power of 2 grams. The lightest paprika weighs 20 grams, while the largest one weighs 2k grams.
Residents of Byteland don't like buying pieces of paprika and so salesmen are forced to sell only whole paprika. What is more, bytean people are very exact and they do not tolerate situations when salesman is not able to sell the exact weight of paprika they are willing to buy. This causes stress among all salesmen of Byteland - some cases of insomnia have been observed as well. One of your friends, who owns vegetable garden, asked you to write a program which is supposed to help salesmen.
Write a program which:
The first line of the input contains one integer k (1 ≤ k ≤ 10), meaning that weights of available paprika are from the set 20, 21, ..., 2k. Second line contains k + 1 positive integers p0, p1, ..., pk not greater than 1 000, separated with single spaces and representing the current stock: p0 paprika of weight 1 gram, p1 - of weight 2 grams, ..., pk - of weight 2k grams.
The first and only line of the output should contain one positive integer x - the smallest weight that cannot be weighed without cutting any paprika.
2 2 1 1
All weights from 1 to 8 can be weighed using paprika on the stock: 1 = 1, 2 = 1 + 1, 3 = 1 + 2, 4 = 4, 5 = 1 + 4, 6 = 1 + 1 + 4, 7 = 1 + 2 + 4, 8 = 1 + 1 + 2 + 4. Value 9 can not be weighed, therefore it is the answer to the example.