All Submissions


Statement

Mumbai is famous for its heavy rains. In a particular locality the arrangement of towers is such:
There is a chain of towers with no spaces in between, all having the same cross section of 1 unit square. The height of these buildings is given to you in an array. Water gets collected between them during rains. People living there decide to collect and store this. Your job is to calculate the amount of water that gets collected between these towers.

Input
First line contains T (number of test cases).
Each test case contains 1 line: size(N) and elements of the array.

Output
For each test case print the amount of water collected, in a separate line.

Sample Input
1
5 1 5 3 7 2

Sample Output
2

Constraints
T<=500
N<=1000

Problem Setter: Shradha Chhaparia


Languages: Brain,C,C++,Java,C#,JavaScript,Pascal,Perl,PHP,Python,Ruby,Text

Time Limit: 1 Second(s)
Score: 0 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0