Tile Laying#1898

Tile Laying

1 second
64 megabytes
Very easy

Renowned programmer Petryk has started developing a new platformer-style computer game. In one of the levels, there is a corridor divided into equal sections. The corridor must be covered with tiles. Each tile can have any length and can cover several consecutive sections. You must arrange the tiles so that each section is covered by the specified number of tiles. Help Petryk determine the minimum number of tiles needed for this.

Input

The first line contains an integer (1 \leq N \leq 200000), which is the length of the corridor. The second line contains integers, each representing the number of tiles that must cover the corresponding section. All numbers are non-negative and do not exceed 10^9.

Output

Output the minimum number of tiles required for the tiling.

Examples

Example 1

Loading
Loading