beecrowd | 2565

Test Tubes

By Ricardo Oliveira, UFPR BR Brazil

Timelimit: 1

The Chemical Engineering (CE) building is a large building that has just opened in the campus. After entering the building looking for a bathroom, you entered the Chemical lab by mistake! Fortunately, the instructor allowed your presence in there.

There are N test tubes in the lab, numbered from 1 to N. Tube i (1 ≤ iN) initially contains mi milliliters of water. For each tube, you can keep it unchanged, you can remove any amount of water from it, or you can put any amount of water in it. Your goal is to make all tubes contain the same amount of water.

In order to put X milliliters of water in some tube, you need to take X milliliters of water from a tap in the lab. Also, in order to remove X milliliters of water from some tube, you need to dump X milliliters of water on a drain in the lab. The total cost is equal to the sum of the total amount of water taken from the tap and the total amount of water dumped on the drain.

Given the initial amount of water in each tube, your task is to determine the minimum total cost needed to make all tubes contain the same amount of water.

Input

The input contains several test cases. The first line of each test case contains the integer N (1 ≤ N ≤ 100), the number of test tubes in the lab. Next lines contain, one per line, N real numbers mi (0 ≤ mi ≤ 100.0), the initial amount of water in each tube, in milliliters.

The input ends with end-of-file (EOF).

Output

For each test case, print a single line containing the minimum total cost needed to make all tubes contain the same amount of water. Round and print the value with exactly two decimal places.

Input Sample Output Sample

3
1.0
1.0
0.9
3
42.0
42.4
41.7

0.10
0.70