AT_past17_n ソフトウェアアップデート
Description
Takahashi is going to update $ N $ apps numbered app $ 1 $ , app $ 2 $ , $ \ldots $ , and app $ N $ .
Updating app $ i $ $ (1\leq i\leq N) $ costs $ T_i $ units of time.
Takahashi can choose the order of the apps to update.
Starting at time $ 0 $ , his computer updates the apps one by one in the specified order.
Formally, if he lets the $ i $ -th ( $ 1\leq i\leq N $ ) app to be updated be app $ p_i $ , the computer behaves as follows:
- updates app $ p_k $ from time $ (T_{p_1}+T_{p_2}+\cdots+T_{p_{k-1}}) $ to time $ (T_{p_1}+T_{p_2}+\cdots+T_{p_{k-1}}+T_{p_k}) $ .
He wants to choose the order so that, when he checks the progress during the updates, he can estimate the total duration required for the entire updates as correctly as possible.
However, during the updates, he only has access to a single integer $ k $ , which indicates that the $ k $ -th update is underway.
If he recognizes that the $ k $ -th update is underway at time $ t $ , he estimates that the duration of the entire updates is $ f(t)=\frac{N}{k-0.5}\cdot t $ .
Here, at the time when the $ i $ -th update starts, he recognizes that the $ i $ -th update is underway. Specifically, at time $ 0 $ he regards that the $ 1 $ -st update is underway; at the time when the $ i $ -th update finishes and $ (i+1) $ -th update starts, he regards that the $ (i+1) $ -th update is underway.
Let $ S\left(=\displaystyle\sum_{i=1}^N T_i\right) $ be the total duration for the entire updates. Suppose he estimates the duration of the entire updates at time $ t $ , which is a random real variable chosen from $ 0 $ (inclusive) to $ t $ (exclusive) uniformly at random. Find the minimum expected value of $ \lvert f(t)-S\rvert $ when he chooses the permutation to minimize it.
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ T_1 $ $ T_2 $ $ \ldots $ $ T_N $
Output Format
Print the expected value of $ \lvert f(t)-S\rvert $ when he chooses the permutation to minimize it.
Your answer is considered correct if the absolute or relative error from the true value is at most $ 10^{-6} $ .
Explanation/Hint
### Sample Explanation 1
The total duration of the entire updates is $ S=3+7=10 $ .
When he specify the updating order of the apps to be $ 1\to 2 $ , his estimated duration $ f(t) $ of the entire updates if he checks the progress at time $ t $ ( $ 0\leq t