449. Save Rain Water
Given the current importance of rainwater harvesting, Ram has started collecting rainwater. He has placed boxes of different heights on the ground, and water is collected between two boxes. Ram wants to know the total amount of water stored between the boxes.
The first line of input will contain the size of the array. The next line will contain the heights of the boxes.
Print a single integer representing the total amount of water trapped.
6 4 2 0 3 2 5
1 <= n <= 2 * 10^4 0 <= a[i] <= 10^5