 Incomplete Array
##### Submissions: 1024   Accuracy: 25.41%   Difficulty: Easy   Marks: 2

You are given an array of size N. Two variables A and B are defined as minimum and maximum in the array respectively. Your task is to find how many number should be added to the given array such that all the element in the range [A,B] occurs atleast once in the array.

Input:

The first line of the input contains an integer T, denoting number of test cases. The first line of each test case contains an integer N denoting the size of the array. The second line of each test cases N space separated integers.

Output:

For each test case, print the count of total numbers of added integers in the array.

Constraints:

1<=T<=2.3*10^3
1<=N<=10^3
Each element in the array will be in range [1,1000]

Example:
Input

2
5
4 5 3 8 6
3
2 1 3

Output
1
0

Note: Time Limit : 0.3 sec

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

Author: ShivamKD

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.