Ball collisions

Given N balls on a line, each picking a direction at random, find the expected number of collisions within time T.

Medium4ProbabilityBrute forceMathImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

NN balls of equal weight and zero size sit on a straight line.

When a ball rolling right and a ball rolling left meet at the same speed, neither speed changes and the two balls only swap directions.

You are given the positions of the NN balls. Hyobin picks the direction of each ball independently, right or left, each with probability 1/21/2. At time 0 every ball starts rolling in its chosen direction, and every ball moves 1 unit per second.

Find the expected number of collisions that happen within TT seconds. A collision at exactly TT seconds counts.

Input

The first line contains the number of balls NN (1N121 \le N \le 12).

The second line contains the NN ball positions. Each position is an integer between 0 and 100,000,000, and no two positions are equal. The positions are not necessarily sorted.

The third line contains the time TT, an integer between 1 and 100,000,000.

Output

Print the expected number of collisions within TT seconds on one line.

The expected value is always a multiple of 0.250.25. Write only as many digits after the decimal point as needed, keeping at least one, so the digits after the point are 0, 25, 5, or 75. Print 0.0 for an expected value of 00, 16.5 for 16.516.5, and 12.75 for 12.7512.75.