This page is still under construction.

Parts of this page are still being built. What you see may change.

Match of the Century

Time limit2sMemory limit256 MB

Summary
Given 2n distinct heights, randomly split into two teams of n, then order one team by decreasing height and the other by increasing height; find the expected sum of same-position height differences.
Level

Hard8 of 10

Topics
Combinatorics, Math, Sorting, Probability
Solved
No attempts yet

Problem

Every year, students of the Intergalactic Institute of Physical Education and Theology hold a "match of the century" in space football. The match lasts one light day, and players from the national teams of all the institute's faculties take part in it.

Before the match begins, the referee has to divide all the players into two teams and assign them numbers. In total, 2n2n players take part in the match, of which the referee sends nn randomly chosen players to the first team and the remaining nn to the second. After that, the referee assigns numbers to all players of both teams.

Players of both teams receive numbers, each of which is an integer from 1 to nn. The numbers of all players of one team are pairwise distinct. Traditionally, in the first team players receive numbers in decreasing order of their height, and in the second, in increasing order.

Students who have seen many matches of the century like to calculate the "entertainment" of each match: the sum of pairwise height differences between players of different teams who have the same number. For example, if the first team has players of height 180 and 190 centimeters, and the second has players of height 170 and 205 centimeters, then the entertainment of this match is ∣180−205∣+∣190−170∣=45|180 - 205| + |190 - 170| = 45. Now they want to compute the expected value of the entertainment of the "match of the century", knowing the height of all its participants. Help them.

Input

The first line of the input contains a natural number tt, the number of matches of the century to be studied. This is followed by descriptions of the matches themselves.

The description of each match consists of two lines. The first line contains a single even natural number 2n2n, the number of participants in the next "match of the century". The next line contains 2n2n pairwise distinct natural numbers not exceeding 10610^6, the heights of all participants.

The total number of participants in all matches to be studied does not exceed 10610^6.

Output

For each match, output on a separate line a single real number: the required expected value. Your answer must differ from the correct one by no more than 10−610^{-6}.

Examples1

  1. Example 1

    Input
    1
    4
    20 30 10 40
    
    Expected output
    40.0