407244: GYM102700 N Name this problem
Description
Jolany is a little girl who lives in a faraway galaxy where the time travel (only to the future) is allowed. Today is Jolany's birthday and she received her first time travel machine as a gift from her parents.
In order to receive more gifts, she wants to use her new time machine to jump directly to her next birthday, exactly one year from now. A year on her planet has $$$n$$$ days.
Time machines on her planet have two nice properties:
- A machine can only be used once per day
- A machine is non-deterministic and each day it will work with a different probability. If the machine works the time traveler will go directly to the desired date
Jolany set her machine to send her $$$n$$$ days to the future and then she wrote down in a piece of paper a list with the probabilities that the machine works for each of the n days.
Unfortunately, she pushed the "hard mode" button in the machine, this button hides the array of probabilities to the user and then applies a random permutation to it, know the machine won't work with the original array but with a hidden permutation of it. Notice that there are always $$$n!$$$ different and equally probable permutations of the original array.
The only information Jolany has is the original array of probabilities and she wants to know the expected number of days she needs to wait until her next birthday. Can you help her?
InputThe first line contains integer $$$n$$$ ($$$1 \le n \le 5000 $$$) — The number of days in a year in Jolany's planet.
The second line contains $$$n$$$ numbers — The original array of probabilities. Every probability is between 0 and 1 (inclusive) and has at most 4 digits after the decimal point.
OutputOutput one line containing the answer to the task. Your answer will be considered correct if the absolute or relative error is at most $$$10^{-6}$$$.
ExamplesInput1 0.2Output
0.800000000000Input
2 0.5 1.0Output
0.250000000000Input
3 0.3 0.1 0.1Output
2.090333333333Note
In the first example the machine will work with probability 0.2 otherwise Jonaly will need to wait one day so the answer is $$$0.2 * 0 + 0.8 * 1$$$.
In the second example there are 2 possible equally probable arrays [0.5, 1] with expected value $$$0.5$$$ and [1, 0.5] with expected value $$$0$$$. So, the answer is $$$0.25$$$.