#P1995E2. Let Me Teach You a Lesson (Hard Version)

    ID: 10712 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 10 Uploaded By: Tags>data structuresdpmatricestwo pointers*2900

Let Me Teach You a Lesson (Hard Version)

Description

This is the hard version of a problem. The only difference between an easy and a hard version is the constraints on tt and nn. You can make hacks only if both versions of the problem are solved.

Arthur is giving a lesson to his famous 2n2 n knights. Like any other students, they're sitting at the desks in pairs, but out of habit in a circle. The knight 2i12 i - 1 is sitting at the desk with the knight 2i2 i.

Each knight has intelligence, which can be measured by an integer. Let's denote the intelligence of the ii-th knight as aia_i. Arthur wants the maximal difference in total intelligence over all pairs of desks to be as small as possible. More formally, he wants to minimize max1in(a2i1+a2i)min1in(a2i1+a2i)\max\limits_{1 \le i \le n} (a_{2 i - 1} + a_{2 i}) - \min\limits_{1 \le i \le n} (a_{2 i - 1} + a_{2 i}).

However, the Code of Chivalry only allows swapping the opposite knights in the circle, i.e., Arthur can simultaneously perform ai:=ai+na_i := a_{i + n}, ai+n:=aia_{i + n} := a_i for any 1in1 \le i \le n. Arthur can make any number of such swaps. What is the best result he can achieve?

Each test consists of several test cases. The first line contains a single integer tt (1t100001 \le t \le 10\,000) — the number of test cases. It is followed by descriptions of the test cases.

The first line of each test case contains a single integer nn (1n1000001 \le n \le 100\,000) — the number of desks.

The second line consists of 2n2n integers a1,a2,,a2na_1, a_2, \ldots, a_{2 n} (1ai1091 \le a_i \le 10^9) — the intelligence values of the knights.

It is guaranteed that the sum of nn over all test cases does not exceed 100000100\,000.

For each test case, output a single line containing one integer — the minimal difference Arthur can achieve.

Input

Each test consists of several test cases. The first line contains a single integer tt (1t100001 \le t \le 10\,000) — the number of test cases. It is followed by descriptions of the test cases.

The first line of each test case contains a single integer nn (1n1000001 \le n \le 100\,000) — the number of desks.

The second line consists of 2n2n integers a1,a2,,a2na_1, a_2, \ldots, a_{2 n} (1ai1091 \le a_i \le 10^9) — the intelligence values of the knights.

It is guaranteed that the sum of nn over all test cases does not exceed 100000100\,000.

Output

For each test case, output a single line containing one integer — the minimal difference Arthur can achieve.

Sample Input 1

5
2
6 6 4 4
1
10 17
3
1 10 1 10 1 10
3
3 3 4 5 5 4
5
1 2 3 4 5 6 7 8 9 10

Sample Output 1

0
0
0
2
4

Note

In the first test case, Arthur can swap the second and the fourth knights. Then the total intelligence at both desks will be 1010.

In the third test case, Arthur can make 00 operations, which will result in the total intelligence of 1111 at each of the desks.

In the fourth test case, Arthur can swap knights with indices 22 and 55 and achieve the difference of 22. It can be proven that he cannot improve his result any further.