#d2674. 翻越建筑
翻越建筑
Crossing the Buildings
Problem Description
There are buildings, numbered to from left to right. Building has height , and building has height .
You start from building with initial energy , and each step you jump to the next building on the right. Suppose you are currently at building with energy , and you jump to building :
- If , you lose energy;
- Otherwise you gain energy.
Your energy must never drop below during the whole process. Find the minimum initial energy (rounded up) required to successfully reach building .
Input Format
The first line contains an integer .
The second line contains space-separated integers , the heights of the buildings.
Output Format
Output one integer, the minimum initial energy required (after rounding up).
Sample Input
5
3 4 3 2 4
Sample Output
4