As the member of Water resources bureau (水利局), Your job is to compute the total volume of Reservoir (水庫) by an elevation map.
Take an example below:

The above elevation map can be represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 unit of water is the total volume of Reservoir (水庫)
Note that: If you are using visual studio, add #pragma warning(disable:4996) in the first line so that you can use scanf on your local machine.
N
S_1 S_2 ... S_N
Given an elvation map with the length of N ( 3 <= N < 3000) with each element S_i (0 <= S_i < 1000)
Compute the total volume of Reservoir (水庫).(followed by an newline character at the end of output string)