Morning light hits the lily shoals of Padmore as Jaya unrolls the day's manifest of panels. The tally will decide the next shipment. 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 <= 2703; 0 <= a[i] <= 1000.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= n <= 2703; 0 <= a[i] <= 1000.
