Two Matchings
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

A permutation of length n is an array , which contains every integer from 1 to n (inclusive) and each number appears exactly once. For example, p=[3,1,4,6,2,5] is a permutation of length 6.

Let's call a permutation is a matching if and only if and for all valid i.

You are given an array (, and n is even). Define the cost of a permutation is .

Define two matchings p, q are combinable if and only if for all i from 1 to n.

Please find two combinable matchings such that the sum of the cost of these two matchings is as small as possible. Output the sum.

输入描述:

The first line contains one integer t () --- the number of test cases.

Each test contains two lines. The first line contains one integer n ( and n is even), The second line contains n integers ().

The sum of n across the test cases doesn't exceed .

输出描述:

For each test, output one line which contains only one integer representing the answer of this test.
示例1

输入

复制
2
4
0 8 0 0
6
3 1 4 1 5 9

输出

复制
16
16

说明

In the first test, one possible combinable matchings with the minimum sum of cost are [2,1,4,3] and [4,3,2,1]. The cost of the first matching is (|0-8| + |8-0| + |0-0| + |0-0|) / 2 = 8, the cost of the second matching is (|0-0| + |8-0| + |0-8| + |0-0|) / 2 = 8. So their sum is 8+8=16.