BETA

#### Submissions: 4818 Accuracy: 54.05%

Maximum Difference

Given an array C[] of integers, find out the maximum difference between any two elements such that larger element appears after the smaller number in C[].
Examples: If array is [2, 3, 10, 6, 4, 8, 1] then returned value should be 8 (Diff between 10 and 2). If array is [ 7, 9, 5, 6, 3, 2 ] then returned value should be 2 (Diff between 7 and 9).

Input:

The first line of input contains an integer T denoting the number of test cases.
The first line of each test case is N,N is the size of array.
The second line of each test case contains N input C[i].

Output:

Print the maximum difference between two element. Otherwise print -1

Constraints:

1 ≤ T ≤ 80
2 ≤ N ≤ 100
1 ≤ C[i] ≤ 500

Example:

Input:
2
7
2 3 10 6 4 8 1
5
1 2 90 10 110

Output:
8
109

#### ** For More Input/Output Examples Use 'Expected Output' option **

##### It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.