CodeLab Academy 📞 9936 6696
← List Python · Level 10: Algorithms Code · 100 points ← #941 #943 →

#942. Rain water

You get the heights of columns. After the rain, how many units of water stay trapped between them? ### Input The first line has n, the second line has n integers separated by spaces. ### Output A number.

Examples

Input
5
6 4 1 7 3
Output
7
Input
14
6 0 4 2 1 1 5 0 6 0 1 4 0 7
Output
48

💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.

🔒 You can solve the first 3 problems without an account. Sign up for free to solve this one!