Logarithmic Paprika [B]
Memory limit: 64 MB
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 grams. The lightest paprika weighs grams,
while the largest one weighs 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.
Task
Write a program which:
- reads a description of the current stock of paprika from the standard input,
- determines the smallest weight of a paprika that cannot be weighed without cutting any paprika,
- writes the result to the standard output.
Input
The first line of the input contains one integer (),
meaning that weights of available paprika are from the set .
Second line contains positive integers not greater than ,
separated with single spaces and representing the current stock: paprika of weight gram, -
of weight grams, ..., - of weight grams.
Output
The first and only line of the output should contain one positive integer -
the smallest weight that cannot be weighed without cutting any paprika.
Example
For the input data:
2
2 1 1
the correct result is:
9
Example description: All weights from to can be weighed using paprika on the stock:
, , , , , , , .
Value can not be weighed, therefore it is the answer to the example.
Task author: Jakub Radoszewski.