AdvancedRating 1700
Trapped Rain
Bars of the given heights stand side by side. Print how much rain water is trapped between them.
Input
n, then n heights.
Output
A number.
Sample 1
Input
12 0 1 0 2 1 0 1 3 2 1 2 1
Output
6
Sample 2
Input
6 4 2 0 3 2 5
Output
9
Output appears here