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.
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.
For each test case, print the count of total numbers of added integers in the array.
Each element in the array will be in range [1,1000]
4 5 3 8 6
2 1 3
Note: Time Limit : 0.3 sec
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.