Under construction

Still being built. Things may change

Twinkle Twinkle 2

Time limit1sMemory limit1024 MB

Summary
Each light has an on-probability; an added light between neighbors turns on exactly when one neighbor is on. Find the expected total number of lit lights.
Level

Easy3 of 10

Topics
Probability, Math, Implementation, Array
Solved
No attempts yet

Problem

Last winter, Suhyeon used a strip of lights to decorate a Christmas tree. Gukryeol stole the leftover strip and wants to use it to decorate his room.

The strip has NN lights arranged in a straight line. Each light has its own probability of turning on when power is applied.

Gukryeol, an electronics expert, rewired the circuit so that one light failing does not affect the others. He still did not find it twinkly enough, so he added one extra light between every pair of adjacent lights on the strip. An extra light turns on only when exactly one of the two lights next to it turns on.

Find the expected number of lights on the strip that turn on.

Input

The input is given as follows.

NN p1p_1 ⋯\cdots pNp_N

  • NN is the number of lights. (1≤N≤100 0001 \le N \le 100\,000)
  • pip_i is the probability that the ii-th light turns on, given with exactly two digits after the decimal point. (0≤pi≤10 \le p_i \le 1)

Output

Print the expected number of lights that turn on.

The absolute or relative error from the correct answer must be at most 10−610^{-6}.

Examples2

  1. Example 1

    Input
    2
    0.50 0.50
    
    Expected output
    1.5
    
  2. Example 2

    Input
    3
    0.30 0.40 0.50
    
    Expected output
    2.16