Problem: You always wanted to be a soldier and play it out at the battleground live. When you came at Techfest 2013, you encountered Lazer Tag, a game that satiated your innate hunger for taking aim and shooting enemies. 
Lazer Tag consists of a group play, where you are assigned a fixed number of bullets (popularly known as Laser shots) during the whole game. Each right shoot on your target enemy, gives you one point. 
 Consider the series of your hits and misses which can be represented in the form of “x” and “o” where “o” represents a hit and “x” represents a miss. Suppose the series is of the form “xxxoooxxxxooxxo” Then your final score will be = 3^2 + 2^2 +1^2 i.e add up the squares of every maximal number of consecutive hits in the entire game play. 
 The probability of hitting the jth shot correctly (1≤j≤n) is P(j). In simpler terms, the probability of getting an “o” in the series at jth turn is P(j). You need to calculate the expected score at the end of your round.
 

Input
The input consists of an integer n - number of shots. In the next line, n space-separated real numbers p(1) p(2) p(3) p(4) ...... p(n) 
 

Output
Print a single number - Expected score for the play. Answer will be correct if absolute or relative error doesn't exceed 10 ^-6
 

Constraints
1 ≤ n ≤ 10^5 
0 ≤ p(j) ≤ 1 
There will be atmost six digits after decimal point in given p(j).
 

Example
Input:
3
1 1 1

Output:
9.000000 

Input:
4
0.6 0.5 0.8 0.2
Output:
4.556000

Solution (in PYTHON):

Solution:
n = int(raw_input())
p = map(float, raw_input().split())

e = [p[0]]
for i in range(1,n):
    ans = (e[i-1]+p[i-1]+1)*p[i]
    e.append(ans)
    
for i in range(n-1):
    e[i+1]+=e[i]
    
print e[n-1]