Problems
548 - Maximum Difference
SUBMIT PROBLEM

Maximum Difference

Time Limit: 0.5 sec

 

The Problem

Given an array with n elements. You have to find the maximum difference between any two elements of the array.

 

The Input

Input starts with an integer T (1 ≤ T ≤ 10), denoting the number of test cases.

Each case contains a single integer n (2 ≤ n ≤ 15), denoting the size of the array.

Next line contains n space separated integers in range [1, 100].

 

The Output

For each case, just print the answer (maximum difference).

 

Sample Input

2

5

1 2 7 3 5

2

5 5

 

Sample Output

6

0

 

 

Note:

In case 1, maximum difference is 7 – 1 = 6.

In case 2, maximum difference is 5 – 5 = 0.

 

 

Problem Setter: Sheikh Monir [Bangabandhu Sheikh Mujibur Rahman Science and Technology University]