Solved by 41 users: fetetriste, svirg, vi002, HeaDacHe, WsemirZ, zloy_mipt, rvashegin, JohnJones_001, FordPerfect, Cheryl, arti, Chmeli_BSU, lutyj, ignat, tourist, pmnox, tomek, mazahaka, UdH-WiNGeR, Philip_PV, defrager, RAVEman, knightry, wangyc, Jacob, daniel.ugra, DAV, Dest, mathematic, DD, Kuznetsov_S, ripatti, vitar, mkirsche, Fat, Bryak211, akk, checkil, NIGHTFIT, avg79, ilia.
` <  <  <  <  <  <  <  <  <  < `

## Taxi 5

Time limit = 2 second(s)

Memory limit = 4000

Taxi driver Daniel likes to tell funny jokes to his passengers. He thinks that his duty is to tell two funny jokes to each passenger. But if a passenger doesn't laugh at а joke, he concludes that the joke is not so funny and then he will never tell this joke.

Daniel knows N funny jokes. He knows the funnitude of each joke — the probability of the event that a randomly choosed passenger will laugh at this joke.

Daniel can't invent new jokes. And when less than two jokes remain, he gives up driving. But he loves driving. Therefore he tells the jokes in that order to maximize the expected number of runs.

You task is to determine the expected number of runs.

Input The first line contains an integer number N, 0 ≤ N ≤ 10000. The second line contains N numbers pi — the funnitudes of the jokes, 0 ≤ pi ≤ 0.9999.

Output One number — expected value of the number of runs. The relative error mustn't be greater than 10-9.

 Input#1```2 0.5 0.5 ``` Output#1```1.33333333333333 ```
 Input#2```5 0.8 0.8 0.9 0.9 0.8 ``` Output#2```14.5876548893019 ```

Author:
Alexander Potashev, thanks to Eugene Barsky for the algorithmic idea.
24 May 2008

 © acm.mipt DevGroupThe page was generated in 180ms