Problem H
Disastrous Downfall
There is a heavy rainfall over the Antique Cultural Museum, and the roof has sprung a leak! All the beautiful paintings risk destruction, if it weren’t for one brave night watchman standing in the water’s way – Klunkas Plaskocek.
To protect all of the paintings, Klunkas has brought
Klunkas needs your help to prevent the leftmost bucket overflowing. After every drop of water falls, Klunkas wants to know which bucket it ended up in, so that he can keep track of the water levels of the buckets.
Due to the very regular nature of rain, Klunkas figured that
the
The bucket which the
Input
Input consists of the space-separated integers
Output
If the leftmost bucket overflows, output “OVERFLOW”.
Otherwise, the output should be calculated as follows:
Let
Then, for every
The output should then be a line with the integer
Sample Input 1 | Sample Output 1 |
---|---|
10 6 1 2 1 8 |
OVERFLOW |
Sample Input 2 | Sample Output 2 |
---|---|
10 6 1 4 1 8 |
79732 |
Sample Input 3 | Sample Output 3 |
---|---|
10 20 2 8 7 3 |
31786 |