#P1954E. Chain Reaction
Chain Reaction
No submission language available for this problem.
Description
There are monsters standing in a row. The -th monster has health points.
Every second, you can choose one alive monster and launch a chain lightning at it. The lightning deals damage to it, and also spreads to the left (towards decreasing ) and to the right (towards increasing ) to alive monsters, dealing damage to each. When the lightning reaches a dead monster or the beginning/end of the row, it stops. A monster is considered alive if its health points are strictly greater than .
For example, consider the following scenario: there are three monsters with health equal to , and . You can kill them all in seconds:
- launch a chain lightning at the -rd monster, then their health values are ;
- launch a chain lightning at the -st monster, then their health values are ;
- launch a chain lightning at the -rd monster, then their health values are ;
- launch a chain lightning at the -th monster, then their health values are .
For each from to , calculate the minimum number of seconds it takes to kill all the monsters.
The first line contains a single integer () — the number of monsters.
The second line contains integers () — the health points of the -th monster.
For each from to , output the minimum number of seconds it takes to kill all the monsters.
Input
The first line contains a single integer () — the number of monsters.
The second line contains integers () — the health points of the -th monster.
Output
For each from to , output the minimum number of seconds it takes to kill all the monsters.