Every season at the alabaster quarry of Whitestone, someone must decode the foreman's shorthand notes. This year the task falls to Jeweler, armed only with the scrolls register. Task: Heights a[i] form a skyline; after rain, water rests between higher bars. Print the total trapped water. Input format: First line: n. Second line: n nonnegative integers. Output format: Print the trapped water volume (fits 64-bit). Constraints: 1 <= n <= 1543; 0 <= a[i] <= 1000000000.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= n <= 1543; 0 <= a[i] <= 1000000000.
