Patrick is engaged in the WarFire game, where the objective is to assemble two teams from a pool of N players represented by an array A. Each player possesses a specific power level, and the cumulative power level of a team is determined by the sum of individual player powers.
To ensure a closely contested match between the two teams, Patrick aims to minimize the gap in power levels between them.
Your task is to help Patrick and complete the challenge of finding the smallest possible gap between the total power levels of both teams.
Input Format:
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
The first line contains T denoting the number of test cases. T also specifies the number of times you have to run the solve function on a different set of inputs.
For each test case:
Output Format:
For each test case, print the answer in a new line.
Constraints:
1≤T≤101≤N≤1031≤A[i]≤103N∗(Sum of elements)≤106
The teams can be formed with power level difference of 1, by teaming players with power level [1,6,2,2] in one group and [10] in the other group. So the power levels of both teams are 11 and 10 repectively and difference being 1.