#P1654. OSU!

OSU!

Description

osu is a popular casual game.

We can simplify and adapt its rules as follows:

There are nn operations. Each operation is either a success or a failure, where success is denoted by 11 and failure by 00. The nn operations form a binary string of length nn. In this string, every maximal run of XX consecutive 11's contributes X3X^3 points to the score (i.e., these XX ones must not be contained within a longer run of consecutive 11's; see the sample explanation).

Given nn and the success probability of each operation, output the expected score, rounded to 1 decimal place.

Input Format

The first line contains a positive integer nn, the number of operations.
Each of the next nn lines contains a real number in [0,1][0, 1], denoting the success probability of each operation.

Output Format

Output a single real number, the answer, rounded to 1 decimal place.

3 
0.5 
0.5 
0.5
6.0

Hint

[Sample explanation]

000000 has a score of 00001001 has a score of 11010010 has a score of 11100100 has a score of 11101101 has a score of 22110110 has a score of 88011011 has a score of 88111111 has a score of 2727,the total is 4848, and the expectation is 488=6.0\dfrac{48}8 = 6.0.

Constraints: n1×105n \leq 1 \times 10^5.

Translated by ChatGPT 5