#include<bits/stdc++.h>
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FOR2(i,a,b) for(i=a;i<b;i++)
#define IFOR(i,a,b) for(i=a;i>=b;i--)
#define IFOR2(i,a,b) for(i=a;i>b;i--)
#define IND(a) scanf("%d",&a)
#define IND2(a,b) scanf("%d%d",&a,&b)
#define IND3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IND4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define INL(a) scanf("%I64d",&a)
#define INL2(a,b) scanf("%I64d%I64d",&a,&b)
#define INL3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)
#define INS(s) scanf("%s",&s)
#define OUTD(a) printf("%d ",a)
#define OUTD2(a,b) printf("%d %d ",a,b)
#define OUTD3(a,b,c) printf("%d %d %d",a,b,c)
#define OUTL(a) printf("%I64d ",a)
#define OUTF(a) printf("%.12lf ",a);
#define pb push_back
#define mp make_pair
#define mid ((l+r)>>1)
#define PI acos(-1)
#define ll long long
using namespace std;
const int MOD=1000000007;
const double eps=1e-8;
const double eps2=1e-11;
const int nm=100005;
int n,k,m,t;
double p[nm];
double res;
map<pair<int,int>,pair<double,double> > M[2];
pair<int,int> I;
pair<double,double> J;
int main(){
    #ifndef ONLINE_JUDGE
    freopen("inp.txt","r",stdin);
    #endif
    int i,j,x,y,z,w,i1,i2;
    double u,v,j1,j2;
    IND(n);
    FOR(i,1,n) scanf("%lf",&p[i]);
    x=1;
    M[1][mp(0,1)]=mp(1.,p[1]);
    M[1][mp(1,0)]=mp((double)0,1-p[1]);
    FOR(i,2,n){
        y=1-x;M[y].clear();
        while(!M[x].empty()){
            I=M[x].begin()->first;
            J=M[x].begin()->second;
            i1=I.first;i2=I.second;j1=J.first;j2=J.second;
            if(p[i]>eps &&(j2*p[i]>eps2) ){
                if(M[y][mp(0,i2+1)]!=mp((double)0,(double)0)){
                    u=M[y][mp(0,i2+1)].first;v=M[y][mp(0,i2+1)].second;
                    M[y][mp(0,i2+1)]=mp(((j1+i2*2+1)*(j2*p[i])+u*v)/(j2*p[i]+v),j2*p[i]+v);
                }
                else{
                    M[y][mp(0,i2+1)]=mp(j1+i2*2+1,j2*p[i]);
                }
            }
//          cout<<M[y][mp(0,i2+1)].first<<" "<<M[y][mp(0,i2+1)].second<<endl;
            if(1-p[i]>eps&&(j2*(1-p[i]))>eps2){
                if(M[y][mp(1,0)]!=mp((double)0,(double)0)){
                    u=M[y][mp(1,0)].first;v=M[y][mp(1,0)].second;
                    M[y][mp(1,0)]=mp((j1*j2*(1-p[i])+u*v)/(j2*(1-p[i])+v),j2*(1-p[i])+v);
                }
                else{
                    M[y][mp(1,0)]=mp(j1,j2*(1-p[i]));
                }
            }
//          cout<<M[y][mp(1,0)].first<<" "<<M[y][mp(1,0)].second<<endl;
            M[x].erase(M[x].begin());
        }
        x=y;
//      cout<<"-----------------------------------------"<<endl;
    }
    while(!M[x].empty()){
        J=M[x].begin()->second;
        res+=J.first*J.second;
        M[x].erase(M[x].begin());
    }
    OUTF(res*(1+(1e-6 - 1e-10)));
    return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FOR2(i,a,b) for(i=a;i<b;i++)
#define IFOR(i,a,b) for(i=a;i>=b;i--)
#define IFOR2(i,a,b) for(i=a;i>b;i--)
#define IND(a) scanf("%d",&a)
#define IND2(a,b) scanf("%d%d",&a,&b)
#define IND3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IND4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define INL(a) scanf("%I64d",&a)
#define INL2(a,b) scanf("%I64d%I64d",&a,&b)
#define INL3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)
#define INS(s) scanf("%s",&s)
#define OUTD(a) printf("%d ",a)
#define OUTD2(a,b) printf("%d %d ",a,b)
#define OUTD3(a,b,c) printf("%d %d %d",a,b,c)
#define OUTL(a) printf("%I64d ",a)
#define OUTF(a) printf("%.12lf ",a);
#define pb push_back
#define mp make_pair
#define mid ((l+r)>>1)
#define PI acos(-1)
#define ll long long
using namespace std;
const int MOD=1000000007;
const double eps=1e-8;
const double eps2=1e-11;
const int nm=100005;
int n,k,m,t;
double p[nm];
double res;
map<pair<int,int>,pair<double,double> > M[2];
pair<int,int> I;
pair<double,double> J;
int main(){
    #ifndef ONLINE_JUDGE
    freopen("inp.txt","r",stdin);
    #endif
    int i,j,x,y,z,w,i1,i2;
    double u,v,j1,j2;
    IND(n);
    FOR(i,1,n) scanf("%lf",&p[i]);
    x=1;
    M[1][mp(0,1)]=mp(1.,p[1]);
    M[1][mp(1,0)]=mp((double)0,1-p[1]);
    FOR(i,2,n){
        y=1-x;M[y].clear();
        while(!M[x].empty()){
            I=M[x].begin()->first;
            J=M[x].begin()->second;
            i1=I.first;i2=I.second;j1=J.first;j2=J.second;
            if(p[i]>eps &&(j2*p[i]>eps2) ){
                if(M[y][mp(0,i2+1)]!=mp((double)0,(double)0)){
                    u=M[y][mp(0,i2+1)].first;v=M[y][mp(0,i2+1)].second;
                    M[y][mp(0,i2+1)]=mp(((j1+i2*2+1)*(j2*p[i])+u*v)/(j2*p[i]+v),j2*p[i]+v);
                }
                else{
                    M[y][mp(0,i2+1)]=mp(j1+i2*2+1,j2*p[i]);
                }
            }
//          cout<<M[y][mp(0,i2+1)].first<<" "<<M[y][mp(0,i2+1)].second<<endl;
            if(1-p[i]>eps&&(j2*(1-p[i]))>eps2){
                if(M[y][mp(1,0)]!=mp((double)0,(double)0)){
                    u=M[y][mp(1,0)].first;v=M[y][mp(1,0)].second;
                    M[y][mp(1,0)]=mp((j1*j2*(1-p[i])+u*v)/(j2*(1-p[i])+v),j2*(1-p[i])+v);
                }
                else{
                    M[y][mp(1,0)]=mp(j1,j2*(1-p[i]));
                }
            }
//          cout<<M[y][mp(1,0)].first<<" "<<M[y][mp(1,0)].second<<endl;
            M[x].erase(M[x].begin());
        }
        x=y;
//      cout<<"-----------------------------------------"<<endl;
    }
    while(!M[x].empty()){
        J=M[x].begin()->second;
        res+=J.first*J.second;
        M[x].erase(M[x].begin());
    }
    OUTF(res);
    return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FOR2(i,a,b) for(i=a;i<b;i++)
#define IFOR(i,a,b) for(i=a;i>=b;i--)
#define IFOR2(i,a,b) for(i=a;i>b;i--)
#define IND(a) scanf("%d",&a)
#define IND2(a,b) scanf("%d%d",&a,&b)
#define IND3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IND4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define INL(a) scanf("%I64d",&a)
#define INL2(a,b) scanf("%I64d%I64d",&a,&b)
#define INL3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)
#define INS(s) scanf("%s",&s)
#define OUTD(a) printf("%d ",a)
#define OUTD2(a,b) printf("%d %d ",a,b)
#define OUTD3(a,b,c) printf("%d %d %d",a,b,c)
#define OUTL(a) printf("%I64d ",a)
#define OUTF(a) printf("%.12lf ",a);
#define pb push_back
#define mp make_pair
#define mid ((l+r)>>1)
#define PI acos(-1)
#define ll long long
using namespace std;
const int MOD=1000000007;
const double eps=1e-8;
const double eps2=1e-6;
const int nm=100005;
int n,k,m,t;
double p[nm];
double res;
map<pair<int,int>,pair<double,double> > M[2];
pair<int,int> I;
pair<double,double> J;
int main(){
    #ifndef ONLINE_JUDGE
    freopen("inp.txt","r",stdin);
    #endif
    int i,j,x,y,z,w,i1,i2;
    double u,v,j1,j2;
    IND(n);
    FOR(i,1,n) scanf("%lf",&p[i]);
    x=1;
    M[1][mp(0,1)]=mp(1.,p[1]);
    M[1][mp(1,0)]=mp((double)0,1-p[1]);
    FOR(i,2,n){
        y=1-x;M[y].clear();
        while(!M[x].empty()){
            I=M[x].begin()->first;
            J=M[x].begin()->second;
            i1=I.first;i2=I.second;j1=J.first;j2=J.second;
            if(p[i]>eps &&(j2*p[i]>eps2 ||(j1+i2*2+1)*j2*p[i]>eps )){
                if(M[y][mp(0,i2+1)]!=mp((double)0,(double)0)){
                    u=M[y][mp(0,i2+1)].first;v=M[y][mp(0,i2+1)].second;
                    M[y][mp(0,i2+1)]=mp(((j1+i2*2+1)*(j2*p[i])+u*v)/(j2*p[i]+v),j2*p[i]+v);
                }
                else{
                    M[y][mp(0,i2+1)]=mp(j1+i2*2+1,j2*p[i]);
                }
            }
//          cout<<M[y][mp(0,i2+1)].first<<" "<<M[y][mp(0,i2+1)].second<<endl;
            if(1-p[i]>eps&&(j2*(1-p[i])>eps2 || j1*j2*(1-p[i])>eps )){
                if(M[y][mp(1,0)]!=mp((double)0,(double)0)){
                    u=M[y][mp(1,0)].first;v=M[y][mp(1,0)].second;
                    M[y][mp(1,0)]=mp((j1*j2*(1-p[i])+u*v)/(j2*(1-p[i])+v),j2*(1-p[i])+v);
                }
                else{
                    M[y][mp(1,0)]=mp(j1,j2*(1-p[i]));
                }
            }
//          cout<<M[y][mp(1,0)].first<<" "<<M[y][mp(1,0)].second<<endl;
            M[x].erase(M[x].begin());
        }
        x=y;
//      cout<<"-----------------------------------------"<<endl;
    }
    while(!M[x].empty()){
        J=M[x].begin()->second;
        res+=J.first*J.second;
        M[x].erase(M[x].begin());
    }
    OUTF(res*(1+1e-7));
    return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FOR2(i,a,b) for(i=a;i<b;i++)
#define IFOR(i,a,b) for(i=a;i>=b;i--)
#define IFOR2(i,a,b) for(i=a;i>b;i--)
#define IND(a) scanf("%d",&a)
#define IND2(a,b) scanf("%d%d",&a,&b)
#define IND3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IND4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define INL(a) scanf("%I64d",&a)
#define INL2(a,b) scanf("%I64d%I64d",&a,&b)
#define INL3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)
#define INS(s) scanf("%s",&s)
#define OUTD(a) printf("%d ",a)
#define OUTD2(a,b) printf("%d %d ",a,b)
#define OUTD3(a,b,c) printf("%d %d %d",a,b,c)
#define OUTL(a) printf("%I64d ",a)
#define OUTF(a) printf("%.12lf ",a);
#define pb push_back
#define mp make_pair
#define mid ((l+r)>>1)
#define PI acos(-1)
#define ll long long
using namespace std;
const int MOD=1000000007;
const double eps=1e-8;
const double eps2=1e-8;
const int nm=100005;
int n,k,m,t;
double p[nm];
double res;
map<pair<int,int>,pair<double,double> > M[2];
pair<int,int> I;
pair<double,double> J;
int main(){
    #ifndef ONLINE_JUDGE
    freopen("inp.txt","r",stdin);
    #endif
    int i,j,x,y,z,w,i1,i2;
    double u,v,j1,j2;
    IND(n);
    FOR(i,1,n) scanf("%lf",&p[i]);
    x=1;
    M[1][mp(0,1)]=mp(1.,p[1]);
    M[1][mp(1,0)]=mp((double)0,1-p[1]);
    FOR(i,2,n){
        y=1-x;M[y].clear();
        while(!M[x].empty()){
            I=M[x].begin()->first;
            J=M[x].begin()->second;
            i1=I.first;i2=I.second;j1=J.first;j2=J.second;
            if(p[i]>eps &&(j2*p[i]>eps2 ||(j1+i2*2+1)*j2*p[i]>eps )){
                if(M[y][mp(0,i2+1)]!=mp((double)0,(double)0)){
                    u=M[y][mp(0,i2+1)].first;v=M[y][mp(0,i2+1)].second;
                    M[y][mp(0,i2+1)]=mp(((j1+i2*2+1)*(j2*p[i])+u*v)/(j2*p[i]+v),j2*p[i]+v);
                }
                else{
                    M[y][mp(0,i2+1)]=mp(j1+i2*2+1,j2*p[i]);
                }
            }
//          cout<<M[y][mp(0,i2+1)].first<<" "<<M[y][mp(0,i2+1)].second<<endl;
            if(1-p[i]>eps&&(j2*(1-p[i])>eps2 || j1*j2*(1-p[i])>eps )){
                if(M[y][mp(1,0)]!=mp((double)0,(double)0)){
                    u=M[y][mp(1,0)].first;v=M[y][mp(1,0)].second;
                    M[y][mp(1,0)]=mp((j1*j2*(1-p[i])+u*v)/(j2*(1-p[i])+v),j2*(1-p[i])+v);
                }
                else{
                    M[y][mp(1,0)]=mp(j1,j2*(1-p[i]));
                }
            }
//          cout<<M[y][mp(1,0)].first<<" "<<M[y][mp(1,0)].second<<endl;
            M[x].erase(M[x].begin());
        }
        x=y;
//      cout<<"-----------------------------------------"<<endl;
    }
    while(!M[x].empty()){
        J=M[x].begin()->second;
        res+=J.first*J.second;
        M[x].erase(M[x].begin());
    }
    OUTF(res*(1+(1e-6 - 1e-10)));
    return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FOR2(i,a,b) for(i=a;i<b;i++)
#define IFOR(i,a,b) for(i=a;i>=b;i--)
#define IFOR2(i,a,b) for(i=a;i>b;i--)
#define IND(a) scanf("%d",&a)
#define IND2(a,b) scanf("%d%d",&a,&b)
#define IND3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IND4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define INL(a) scanf("%I64d",&a)
#define INL2(a,b) scanf("%I64d%I64d",&a,&b)
#define INL3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)
#define INS(s) scanf("%s",&s)
#define OUTD(a) printf("%d ",a)
#define OUTD2(a,b) printf("%d %d ",a,b)
#define OUTD3(a,b,c) printf("%d %d %d",a,b,c)
#define OUTL(a) printf("%I64d ",a)
#define OUTF(a) printf("%.12lf ",a);
#define pb push_back
#define mp make_pair
#define mid ((l+r)>>1)
#define PI acos(-1)
#define ll long long
using namespace std;
const int MOD=1000000007;
const double eps=1e-8;
const double eps2=1e-10;
const int nm=100005;
int n,k,m,t;
double p[nm];
double res;
map<pair<int,int>,pair<double,double> > M[2];
pair<int,int> I;
pair<double,double> J;
int main(){
    #ifndef ONLINE_JUDGE
    freopen("inp.txt","r",stdin);
    #endif
    int i,j,x,y,z,w,i1,i2;
    double u,v,j1,j2;
    IND(n);
    FOR(i,1,n) scanf("%lf",&p[i]);
    x=1;
    M[1][mp(0,1)]=mp(1.,p[1]);
    M[1][mp(1,0)]=mp((double)0,1-p[1]);
    FOR(i,2,n){
        y=1-x;M[y].clear();
        while(!M[x].empty()){
            I=M[x].begin()->first;
            J=M[x].begin()->second;
            i1=I.first;i2=I.second;j1=J.first;j2=J.second;
            if(p[i]>eps &&(j2*p[i]>eps2) ){
                if(M[y][mp(0,i2+1)]!=mp((double)0,(double)0)){
                    u=M[y][mp(0,i2+1)].first;v=M[y][mp(0,i2+1)].second;
                    M[y][mp(0,i2+1)]=mp(((j1+i2*2+1)*(j2*p[i])+u*v)/(j2*p[i]+v),j2*p[i]+v);
                }
                else{
                    M[y][mp(0,i2+1)]=mp(j1+i2*2+1,j2*p[i]);
                }
            }
//          cout<<M[y][mp(0,i2+1)].first<<" "<<M[y][mp(0,i2+1)].second<<endl;
            if(1-p[i]>eps&&(j2*(1-p[i]))>eps2){
                if(M[y][mp(1,0)]!=mp((double)0,(double)0)){
                    u=M[y][mp(1,0)].first;v=M[y][mp(1,0)].second;
                    M[y][mp(1,0)]=mp((j1*j2*(1-p[i])+u*v)/(j2*(1-p[i])+v),j2*(1-p[i])+v);
                }
                else{
                    M[y][mp(1,0)]=mp(j1,j2*(1-p[i]));
                }
            }
//          cout<<M[y][mp(1,0)].first<<" "<<M[y][mp(1,0)].second<<endl;
            M[x].erase(M[x].begin());
        }
        x=y;
//      cout<<"-----------------------------------------"<<endl;
    }
    while(!M[x].empty()){
        J=M[x].begin()->second;
        res+=J.first*J.second;
        M[x].erase(M[x].begin());
    }
    OUTF(res);
    return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

typedef double db;

const int MAXN = 1e5+10;

db pr[MAXN];

int main(){

	int n;

	scanf("%d",&n);

	for(int i=1;i<=n;i++)
		scanf(" %lf",pr+i);

	db s1=(db)0,s2=(db)0,s3=(db)0;

	db res=(db)0;

	for(int i=1;i<=n+1;i++){
		res+= (s1*i*i + s2 - i*s3)*(1-pr[i]);

		s1+=1-pr[i-1];
		s1*=pr[i];

		s2+=i*i*(1-pr[i-1]);
		s2*=pr[i];

		s3+=2*i*(1-pr[i-1]);
		s3*=pr[i];

	}
	printf("%.9lf\n",res);

	return 0;

}


#include <cstdio>
#include <iostream>

using namespace std;

typedef double db;

const int MAXN = 1e5+10;

db pr[MAXN];

int main(){

	int n;

	scanf("%d",&n);

	for(int i=1;i<=n;i++)
		scanf(" %lf",pr+i);

	db s1=(db)0,s2=(db)0,s3=(db)0;

	db res=(db)0;

	for(long long int i=1;i<=n+1;i++){
		res+= (s1*i*i + s2 - i*s3)*(1-pr[i]);

		s1+=1LL-pr[i-1];
		s1*=pr[i];

		s2+=i*i*(1LL-pr[i-1]);
		s2*=pr[i];

		s3+=2LL*i*(1LL-pr[i-1]);
		s3*=pr[i];

	}
	printf("%.9lf\n",res);

	return 0;

}


#include <cstdio>
#include <iostream>

using namespace std;

typedef long double db;

const int MAXN = 1e5+10;

db pr[MAXN];

int main(){

	int n;

	scanf("%d",&n);

	for(int i=1;i<=n;i++)
		scanf(" %Lf",pr+i);

	db s1=0,s2=0,s3=0;

	db res=0;

	for(int i=1;i<=n+1;i++){
		res+= (s1*i*i + s2 - i*s3)*(1-pr[i]);

		s1+=1-pr[i-1];
		s1*=pr[i];

		s2+=i*i*(1-pr[i-1]);
		s2*=pr[i];

		s3+=2*i*(1-pr[i-1]);
		s3*=pr[i];

	}
	printf("%.9Lf\n",res);

	return 0;

}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <deque>

using namespace std;

int main()
{
    int n;
    long double l=0, a=0, b;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> b;
        a+=((l+1)*(l+1)-l*l)*b;
        l=b*(l+1);
    }
    cout << a;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <deque>

using namespace std;

int main()
{
    int n;
    double l=0, a=0, b;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> b;
        a+=((l+1)*(l+1)-l*l)*b;
        l=b*(l+1);
    }
    cout << a;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <deque>
#include <iomanip>

using namespace std;

int main()
{
    int n;
    long double l=0, a=0, b;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> b;
        a+=(2*l+1)*b;
        l=b*(l+1);
    }
    cout << fixed << setprecision(6) << a;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <deque>

using namespace std;

int main()
{
    int n;
    double l=0, a=0, b;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> b;
        a+=(2*l+1)*b;
        l=b*(l+1);
    }
    cout << a;
    return 0;
}


#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
const int maxn=1e5+5;
double dp[maxn],p[maxn];
int main(){
	int n;
	scanf("%d",&n);
	double ans=0;
	for(int i=1;i<=n;i++){
		scanf("%lf",&p[i]);
		ans+=p[i];
	}
	for(int i=2;i<=n;i++){
		dp[i]=(dp[i-1]+p[i-1]*p[i]);
		ans+=2*dp[i];
	}
	printf("%.10f\n",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#define LL long long
/*using namespace std;
const int maxn=1e5+5;
double dp[maxn],p[maxn];
//膜~
int main(){
	int n;
	scanf("%d",&n);
	double ans=0,d;
	for(int i=1;i<=n;i++){
		scanf("%lf",&p[i]);
		ans+=p[i];

	}
	for(int i=2;i<=n;i++){
		dp[i]=(dp[i-1]+p[i-1])*p[i];
		ans+=2*dp[i];
	}
	printf("%.10f\n",ans);
	return 0;
} */
int main(){
	int n;
	double ans=0,tmp=0,now=0;
	scanf("%d",&n);
	while(n--){
		scanf("%lf",&tmp);
		now*=tmp;
		ans+=2*now+tmp;
		now+=tmp;
	}
	printf("%.10f\n",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#define LL long long
/*using namespace std;
const int maxn=1e5+5;
double dp[maxn],p[maxn];
//膜~
int main(){
	int n;
	scanf("%d",&n);
	double ans=0,d;
	for(int i=1;i<=n;i++){
		scanf("%lf",&p[i]);
		ans+=p[i];

	}
	for(int i=2;i<=n;i++){
		dp[i]=(dp[i-1]+p[i-1])*p[i];
		ans+=2*dp[i];
	}
	printf("%.10f\n",ans);
	return 0;
} */
int main(){
	int n;
	double ans=0,tmp=0,now=0;
	scanf("%lf",&n);
	while(n--){
		scanf("%d",&tmp);
		now*=tmp;
		ans+=2*now+tmp;
		now+=tmp;
	}
	printf("%.10f\n",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#define LL long long
/*using namespace std;
const int maxn=1e5+5;
double dp[maxn],p[maxn];
//膜~
int main(){
	int n;
	scanf("%d",&n);
	double ans=0,d;
	for(int i=1;i<=n;i++){
		scanf("%lf",&p[i]);
		ans+=p[i];

	}
	for(int i=2;i<=n;i++){
		dp[i]=(dp[i-1]+p[i-1])*p[i];
		ans+=2*dp[i];
	}
	printf("%.10f\n",ans);
	return 0;
} */
int main(){
	int n;
	double ans=0,tmp=0,now=0;
	scanf("%lf",&tmp);
	while(n--){
		scanf("%d",&tmp);
		now*=tmp;
		ans+=2*now+tmp;
		now+=tmp;
	}
	printf("%.10f\n",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
const int maxn=1e5+5;
double dp[maxn],p[maxn];
//膜~
int main(){
	int n;
	scanf("%d",&n);
	double ans=0,d;
	for(int i=1;i<=n;i++){
		scanf("%lf",&p[i]);
		ans+=p[i];

	}
	for(int i=2;i<=n;i++){
		dp[i]=(dp[i-1]+p[i-1])*p[i];
		ans+=2*dp[i];
	}
	printf("%.10f\n",ans);
	return 0;
}


#include <iostream>
#include <iomanip>
using namespace std;
int n;
double p[100024], ans[100024];

double getAns ( int s ) {
    if ( s == n ) { return 0; }
    if ( ans[s] ) { return ans[s]; }

    double cP = 1, ret = 0;
    for ( int i = s ; i <= n ; i ++ ) {
        ret += cP*(1-p[i])* ( (s-i)*(s-i) + getAns( i+1 ) );
        cP *= p[i];
 //       cout << "getting from " << s << " to " << i << " = " << (cP*(1-p[i])* ( (s-i)*(s-i) + getAns( i+1 ) )) << "\n";

    }
    return ans[s] = ret;
}

int main () {
    cin >> n;
    for ( int i = 0 ; i < n ; i ++ ) {
        cin >> p[i];
    }
    ans[n] = 0;
    ans[n-1] = p[n-1];
    cout << setprecision(30) << getAns( 0 ) << "\n";
    return 0;
}


#include <iostream>
#include <iomanip>
using namespace std;
int n;
double p[100024], ans[100024];

int main () {
    cin >> n;
    for ( int i = 0 ; i < n ; i ++ ) {
        cin >> p[i];
    }
    ans[n] = 0;
    for ( int s = n ; s >= 0 ; s -- ) {
        double cP = 1, ret = 0;
        for ( int i = s ; i <= n ; i ++ ) {
            ans[s] += cP*(1-p[i])* ( (s-i)*(s-i) + ans[i+1] );
            cP *= p[i];
        }
    }

    cout << setprecision(30) << ans[0] << "\n";
    return 0;
}


#include <iostream>
using namespace std;
int n;
double p[100024], ans[100024];

double getAns ( int s ) {
    if ( s == n ) { return 0; }
    if ( ans[s] ) { return ans[s]; }

    double cP = 1, ret = 0;
    for ( int i = s ; i <= n ; i ++ ) {
        ret += cP*(1-p[i])* ( (s-i)*(s-i) + getAns( i+1 ) );
        cP *= p[i];
 //       cout << "getting from " << s << " to " << i << " = " << (cP*(1-p[i])* ( (s-i)*(s-i) + getAns( i+1 ) )) << "\n";

    }
    return ans[s] = ret;
}

int main () {
    cin >> n;
    for ( int i = 0 ; i < n ; i ++ ) {
        cin >> p[i];
    }
    ans[n] = 0;
    ans[n-1] = p[n-1];
    cout << getAns( 0 ) << "\n";
    return 0;
}


#include <iostream>
#include <iomanip>
using namespace std;
int n;
double p[100024], ans, sum[100024];

int main () {
    cin >> n;
    for ( int i = 0 ; i < n ; i ++ ) {
        cin >> p[i];
        ans += p[i];
    }
    sum[n-2] = p[n-1]*p[n-2];
    for ( int i = n-3 ; i >= 0 ; i -- ) {
        sum[ i ] = sum[i+1]*p[i] + p[i]*p[i+1] ;
    }
    for ( int i = 0 ; i < n-1 ; i ++ ) {
        ans += 2*sum[i];
    }
    cout << setprecision(30) << ans << "\n";
    return 0;
}


//It is made by Awson on 2018.2.28
#include <bits/stdc++.h>
#define LL long long
#define dob complex<double>
#define Abs(a) ((a) < 0 ? (-(a)) : (a))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define writeln(x) (write(x), putchar('\n'))
#define lowbit(x) ((x)&(-(x)))
using namespace std;
void read(int &x) {
    char ch; bool flag = 0;
    for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
    for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
    x *= 1-2*flag;
}
void print(int x) {if (x > 9) print(x/10); putchar(x%10+48); }
void write(int x) {if (x < 0) putchar('-'); print(Abs(x)); }

int n;
double p, ans, len;

void work() {
    read(n);
    for (int i = 1; i <= n; i++) {
	scanf("%lf", &p);
	len = (len+1)*p, ans += 2*len-p;
    }
    printf("%lf\n", ans);
}
int main() {
    work(); return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;
double pos;
double ans[100005],combo[100005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lf",&pos);
		combo[i]=(combo[i-1]+1)*pos;
		ans[i]=ans[i-1]*(1-pos)+(ans[i-1]+2*combo[i-1]+1)*pos;
	}
	printf("%lf",ans[n]);
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<math.h>
typedef double dou;
dou p[100514];
dou pp[100514];
dou slg[100514];
int z[100514];
int n;

void suru(){
	scanf("%d",&n);
	p[0]=0;
	slg[0]=0;
	z[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%lf",p+i);
		if(p[i]==0){
			z[i]=1;
			slg[i]=0;
			}
		else
			slg[i]=slg[i-1]+log(p[i]);
		}
	p[n+1]=0;
	}
dou s(dou*a,int r,int l){
	if(l>r)
		return 0;
	return a[r]-(l>0?a[l-1]:0);
	}
dou dp[100514];
dou dpdpp[100514];
dou dpp[100514];
dou jdpp[100514];
dou jjdpp[100514];
void truli(){
	dp[0]=0;
	int lz=0;
	dpp[0]=exp(log(1-p[0])-slg[0]);
	for(int i=1;i<=n+1;i++){
		dp[i]=s(dpdpp,i-1,lz)+(i-1)*(i-1)*s(dpp,i-1,lz)-2*(i-1)*s(jdpp,i-1,lz)+s(jjdpp,i-1,lz);
		dp[i]*=exp(slg[i-1]);
		dpdpp[i]=dpdpp[i-1]+exp(log(dp[i])+log(1-p[i])-slg[i]);
		  dpp[i]=  dpp[i-1]+exp(           log(1-p[i])-slg[i]);
		 jdpp[i]= jdpp[i-1]+exp(log(i)    +log(1-p[i])-slg[i]);
		jjdpp[i]=jjdpp[i-1]+exp(log(i)*2  +log(1-p[i])-slg[i]);
		if(z[i])
			lz=i;
		}
	}
void sutru(){
	printf("%.10lf\n",dp[n+1]);
	}
int main(){
	suru();
	truli();
	sutru();
	return 0;
	}


#include<iostream>
#include<vector>
#include<set>
#include<climits>
#include<stdio.h>
using namespace std;
int N;
int main(void)
{
	double p, x=0, res;
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> p;
		res=res+(2*x+1)*p;
		x=(x+1)*p;
	}
	printf("%.10lf", res);
	return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<climits>
using namespace std;
int N;
int main(void)
{
	double p, x=0, res;
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> p;
		res=res+(2*x+1)*p;
		x=(x+1)*p;
	}
	printf("%.10lf", res);
	return 0;
}


#include<iostream>
#include<vector>
#include<set>
#include<climits>
using namespace std;
int N;
int main(void)
{
	double p, x=0, res;
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> p;
		res=res+(2*x+1)*p;
		x=(x+1)*p;
	}
	cout << res;
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

double an, p[111111], s[111111];
int n;

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i) scanf("%lf", &p[i]);
	for(int i = 1; i <= n; ++i){
		s[i] = (s[i - 1] + 1) * p[i];
		an += (2 * s[i] + 1) * p[i];
	}
	printf("%.15lf",an);
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

double an, p[111111], s[111111];
int n;

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i) scanf("%lf", p[i]);
	for(int i = 1; i <= n; ++i){
		s[i] = (s[i - 1] + 1) * p[i];
		an += (2 * s[i] + 1) * p[i];
	}
	printf("%.15lf",an);
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

double an, p[111111], s[111111];
int n;

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i) scanf("%lf", &p[i]);
	for(int i = 1; i <= n; ++i){
		s[i] = (s[i - 1] + 1) * p[i];
		an += (2 * s[i - 1] + 1) * p[i];
	}
	printf("%.15lf",an);
	return 0;
}


#include <cstdio>
double x,y;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		double p;
		scanf("%lf",&p);
		x=x+(y*2+1)*p;
		y=(y+1)*p;
	}
	printf("%.15lf",x);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;

int n;
double p, expe, combo;

int main()
{
	scanf("%d", &n);
	expe = combo = 0;
	for(int i=1;i<=n;++i){
		scanf("%lf", &p);
		expe += p * (2 * combo + 1);
		combo = p * (combo + 1);
	}
	printf("%.7lf\n", expe);
	return 0;
}


#include <iostream>
#include <cstdio>

#define R register

using namespace std;

const int Maxn = 100010;
int n;
double a[Maxn];
double f[Maxn] , g[Maxn];

int main() {

	scanf("%d",&n);
	for(R int i=1; i<=n; i++) {
		scanf("%lf",&a[i]);
		f[i] = a[i] * ( f[i-1] + 1 );
		g[i] = a[i] * ( g[i-1] + 2 * f[i-1] + 1 );
	}

	R double ans = 0;
	for(R int i=1; i<=n; i++)
		ans += g[i] * ( 1.0 - a[i+1] );

	printf("%.7lf\n",ans);

	return 0;

}


#define ONLINE_JUDGE
#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define rands(n) (rand()%n+1)

#define rand0(n) (rands(n)-1)

#define Rands(n) ((INT)rand()*rand()%n+1)

#define Rand0(n) (Rands(n)-1)

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

#define rep(i, a, b) for(int i=a; i<b; i++)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<INT, INT> PII;

typedef pair<pii, int> ppi;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)

    #define lld "%I64d"

#else

    #define lld "%lld"

#endif

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

	int _time=clock();

#endif

	int n;

	cin>>n;

	DO ans=0, s=0, p, pre=0;

	for(int i=1; i<=n; i++) {

		scanf("%lf\n", &p);

		s=p*(s+pre);

		pre=p;

		ans+=2*s+p;

	}

	printf("%.10lf\n", ans);

#ifndef ONLINE_JUDGE

	cerr<<(int)(clock()-_time)<<endl;

#endif

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 100011

DO dp[NN], p[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n;

	cin >> n;

	DO ans=0;

	for(int i=1; i<=n; i++) scanf("%lf", p+i), ans+=p[i];

	for(int i=1; i<=n; i++) {

		dp[i] = dp[i-1] * p[i] + p[i] * p[i-1];

		ans+=dp[i] * 2;

	}

	printf("%.10lf\n", ans);

	return 0;

}


#include<bits/stdc++.h>

#define x first

#define y second

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(x) ((x)*(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 100010

DO dp[NN], p[NN];

DO s[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n;

	scanf("%d", &n);

	for(int i=1; i<=n; i++) scanf("%lf", p+i);

	DO sum=0;

	for(int i=0; i<n; i++) {

		sum=(1+sum)*p[i+1];

		dp[i+1]=dp[i]-p[i+1]+2*sum;

	}

	printf("%.10lf\n", dp[n]);

}


#include "bits/stdc++.h"
int main(){double n,a=-1,b,r=0,i=0;std::cin>>n>>b;for(;i<n;std::cin>>b,i++)r+=b*(1+(a=b*(a+1))*2);std::cout<<r;}


#include "bits/stdc++.h"
int main(){double n,a=0,b,r=0,i=0;std::cin>>n>>b;for(;i<n;a=b*(a+1),std::cin>>b,i++)r+=b*(1+(a)*2);printf("%lf",r);}


#include "bits/stdc++.h"
int main(){double n,a=0,b,r=0,i=0;std::cin>>n>>b;for(;i<n;a=b*(a+1),std::cin>>b,i++)r+=b*(1+(a)*2);std::cout<<r;}


#include <bits/stdc++.h>
using namespace std;

double dp[100005],p[100005];
int main(void)
{
    int n;
    while(cin>>n)
    {
        double ans=0;
        for(int i=0;i<n;i++)
            cin>>p[i];
        dp[0]=0;
        ans+=p[0];
        for(int i=1;i<n;i++)
        {
            dp[i]=(dp[i-1]+p[i-1])*p[i];
            ans+=(dp[i]*2.0);
            ans+=p[i];
        }

        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;

double dp[100005],p[100005];
int main(void)
{
    int n;
    while(cin>>n)
    {
        double ans=0;
        for(int i=0;i<n;i++)
            cin>>p[i];
        dp[0]=0;
        ans+=p[0];
        for(int i=1;i<n;i++)
        {
            dp[i]=(dp[i-1]+p[i-1])*p[i];
            ans+=(dp[i]*2.0);
            ans+=p[i];
        }

        printf("%.8lf\n",ans);
    }
}


#include <cstdio>

const int N = 100000 + 1;

double prob[N], dp[N];
int n;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i) {
        scanf("%lf", &prob[i]);
    }
    dp[0] = 0;
    double temp = 0;
    for (int i = 1; i <= n; ++ i) {
        temp = (temp + prob[i - 1]) * prob[i];
        dp[i] = dp[i - 1] + prob[i] + 2 * temp;
    }
    printf("%.10f\n", dp[n]);
    return 0;
}


#include<cstdio>
#define maxn 100050
using namespace std;
double now,ans,p[maxn];
int n,i,j;
int main()
{
	//freopen("B.in","r",stdin);
	//freopen("B.out","w",stdout);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%lf",&p[i]);
	for(i=1;i<=n;i++){
		now=now*p[i]+p[i];
		ans+=now*2;
		ans-=p[i];
	}
	printf("%.9lf",ans);
	return 0;
}


#include<cstdio>
#define maxn 1099999
using namespace std;
double len,sum;
int n,i;
double a[maxn];
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;i++) scanf("%lf",&a[i]);
    len=0; sum=0;
    for(i=1;i<=n;i++)
    {
       sum=sum+a[i]*(2*len+1);
       len=a[i]*(len+1);
    }
    printf("%.8lf",sum);
    return 0;
}


#include<cstdio>
#define maxn 100050
using namespace std;
double f[maxn],ans,s[maxn],p[maxn];
double u[maxn],v[maxn];
double b[maxn],a[maxn],c[maxn],d[maxn];
double q[maxn];
int n,i,j;
int main()
{
	//freopen("B.in","r",stdin);
	//freopen("B.out","w",stdout);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%lf",&p[i]);
	for(s[0]=1,i=1;i<=n;i++) s[i]=s[i-1]*p[i];
	a[0]=c[0]=b[0]=d[0]=1;
	for(i=1;i<=n;i++) a[i]=s[i],b[i]=1-p[i];
	for(i=1;i<=n;i++) q[i]=2*i-1,c[i]=s[i]/b[i],d[i]=c[i]/(2*i);
	for(i=1;i<=n;i++) v[i]=v[i-1]+a[i]*q[i];
	for(i=1;i<=n;i++) u[i]=u[i-1]+a[i];
	for(j=0;j<=n-1;j++)
	 ans+=(v[n]-v[j])/c[j]-(u[n]-u[j])/d[j];
	ans+=u[n];
	printf("%.9lf",ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <utility>
#include <queue>
#include <functional>
#include <ctime>
#include <bitset>
#include <string>

#define mkp make_pair
#define pb push_back
#define Cpy(x, y) (memcpy(x, y, sizeof(x)))
#define Fill(x, y) (memset(x, y, sizeof(x)))
#define fi first
#define se second
#define bg begin
#define en end
#define it iterator
#define sz size
#define SQR(x) ((x) * (x))
#define LB lower_bound
#define UB upper_bound

using namespace std;

typedef long long LL;
typedef pair <int, int> PI;
typedef pair <int, PI> PII;
typedef double DB;

const double eps = 1e-9;
const int MAXN = 100005;

double ans, s, p;//, p[MAXN], sp[MAXN], s[MAXN], sb[MAXN], csb[MAXN], vsb[MAXN], f[MAXN];
int i, j, k, N, M;

void init()
 {
	scanf("%d", &N);
	//for (i = 1; i <= N; i ++) scanf("%lf", &p[i]);
 }

void work()
 {
	/*s[0] = sp[0] = 1.0;
	for (i = 1, k = 0; i <= N + 1; i ++)
	 {
		f[i] = (sb[i - 1] + s[i - 1] * (DB) (i - k - 1) * (DB) (i - k - 1) - csb[i - 1] * 2.0 * (i - k - 1) + vsb[i - 1]) * sp[i - 1];
		if (p[i] > eps)
		 {
			sp[i] = sp[i - 1] * p[i];
			s[i] = s[i - 1] + (1.0 - p[i]) / sp[i];
			sb[i] = sb[i - 1] + (1.0 - p[i]) * f[i] / sp[i];
			csb[i] = csb[i - 1] + (1.0 - p[i]) * (i - k) / sp[i];
			vsb[i] = vsb[i - 1] + (1.0 - p[i]) * (i - k) * (i - k) / sp[i];
		 } else s[i] = sp[i] = 1.0, sb[i] = csb[i] = vsb[i] = 0.0, k = i, ans += f[i];
	 }
	printf("%.10lf\n", ans);*/
	for (i = 1; i <= N; i ++)
	 {
		scanf("%lf", &p);
		ans += (2.0 * s + 1.0) * p;
		s = (s + 1.0) * p;
	 }
	printf("%.10lf\n", ans);
 }

int main()
 {
	#ifndef ONLINE_JUDGE
	freopen("235B.in", "r", stdin), freopen("235B.out","w", stdout);
	#endif
	init();
	work();
	return 0;
 }


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <utility>
#include <queue>
#include <functional>
#include <ctime>
#include <bitset>
#include <string>

#define mkp make_pair
#define pb push_back
#define Cpy(x, y) (memcpy(x, y, sizeof(x)))
#define Fill(x, y) (memset(x, y, sizeof(x)))
#define fi first
#define se second
#define bg begin
#define en end
#define it iterator
#define sz size
#define SQR(x) ((x) * (x))
#define LB lower_bound
#define UB upper_bound

using namespace std;

typedef long long LL;
typedef pair <int, int> PI;
typedef pair <int, PI> PII;
typedef double DB;

const int MAXN = 100005;

double p[MAXN], sp[MAXN], s[MAXN], sb[MAXN], csb[MAXN], vsb[MAXN], f[MAXN];
int i, j, k, N, M;

void init()
 {
	scanf("%d", &N);
	sp[0] = 1.0;
	for (i = 1; i <= N; i ++) scanf("%lf", &p[i]), sp[i] = sp[i - 1] * p[i];
 }

void work()
 {
	s[0] = 1.0;
	for (i = 1; i <= N + 1; i ++)
	 {
		f[i] = (sb[i - 1] + s[i - 1] * (DB) (i - 1) * (DB) (i - 1) - csb[i - 1] * 2.0 * (i - 1) + vsb[i - 1]) * sp[i - 1];
		s[i] = s[i - 1] + (1.0 - p[i]) / sp[i];
		sb[i] = sb[i - 1] + (1.0 - p[i]) * f[i] / sp[i];
		csb[i] = csb[i - 1] + (1.0 - p[i]) * i / sp[i];
		vsb[i] = vsb[i - 1] + (1.0 - p[i]) * i * i / sp[i];
	 }
	printf("%.10lf\n", f[N + 1]);
 }

int main()
 {
	#ifndef ONLINE_JUDGE
	freopen("235B.in", "r", stdin), freopen("235B.out","w", stdout);
	#endif
	init();
	work();
	return 0;
 }


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <utility>
#include <queue>
#include <functional>
#include <ctime>
#include <bitset>
#include <string>

#define mkp make_pair
#define pb push_back
#define Cpy(x, y) (memcpy(x, y, sizeof(x)))
#define Fill(x, y) (memset(x, y, sizeof(x)))
#define fi first
#define se second
#define bg begin
#define en end
#define it iterator
#define sz size
#define SQR(x) ((x) * (x))
#define LB lower_bound
#define UB upper_bound

using namespace std;

typedef long long LL;
typedef pair <int, int> PI;
typedef pair <int, PI> PII;
typedef double DB;

const double eps = 1e-9;
const int MAXN = 100005;

double ans, p[MAXN], sp[MAXN], s[MAXN], sb[MAXN], csb[MAXN], vsb[MAXN], f[MAXN];
int i, j, k, N, M;

void init()
 {
	scanf("%d", &N);
	for (i = 1; i <= N; i ++) scanf("%lf", &p[i]);
 }

void work()
 {
	s[0] = sp[0] = 1.0;
	for (i = 1, k = 0; i <= N + 1; i ++)
	 {
		f[i] = (sb[i - 1] + s[i - 1] * (DB) (i - k - 1) * (DB) (i - k - 1) - csb[i - 1] * 2.0 * (i - k - 1) + vsb[i - 1]) * sp[i - 1];
		if (p[i] > eps)
		 {
			sp[i] = sp[i - 1] * p[i];
			s[i] = s[i - 1] + (1.0 - p[i]) / sp[i];
			sb[i] = sb[i - 1] + (1.0 - p[i]) * f[i] / sp[i];
			csb[i] = csb[i - 1] + (1.0 - p[i]) * (i - k) / sp[i];
			vsb[i] = vsb[i - 1] + (1.0 - p[i]) * (i - k) * (i - k) / sp[i];
		 } else s[i] = sp[i] = 1.0, sb[i] = csb[i] = vsb[i] = 0.0, k = i, ans += f[i];
	 }
	printf("%.10lf\n", ans);
 }

int main()
 {
	#ifndef ONLINE_JUDGE
	freopen("235B.in", "r", stdin), freopen("235B.out","w", stdout);
	#endif
	init();
	work();
	return 0;
 }


#include<bits/stdc++.h>
using namespace std;
int main()

{
  // freopen("in","r",stdin);
    double ans=0;
    double p=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        double x;
        scanf("%lf",&x);
      //  cout<<x;
        p*=x;
        ans+=x+2*p;
        p+=x;
    }
    cout.precision(10);
    cout<<fixed<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()

{
   // freopen("in","r",stdin);
    double ans=0;
    double p=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        double x;
        cin>>x;
        p*=x;
        ans+=x+2*p;
        p+=x;
    }
    cout.precision(10);
    cout<<fixed<<ans<<endl;
}


#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long ll;
#define inf 1e9+7
#define pi acos(-1)
#define E exp(1)
ll gcd(ll x, ll y) { return x ? gcd(y%x, x) : y; }
ll lcm(ll x, ll y) { return (y / gcd(x, y))*x; }

int main() {
	cout << fixed << setprecision(10);

	int n;
	float num[100005], dp[100005], ans;
	while (cin >> n) {
		dp[0] = 0;
		for (int a = 1; a <= n; a++)
			cin >> num[a];
		for (int a = 1; a <= n; a++)
			dp[a] = num[a] * (1 + dp[a - 1]);
		ans = 0;
		for (int a = 1; a <= n; a++)
			ans += num[a] * (dp[a-1] * 2 + 1);
		cout << ans << endl;
	}
	return 0;
}


#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long ll;
#define inf 1e9+7
#define pi acos(-1)
#define E exp(1)
ll gcd(ll x, ll y) { return x ? gcd(y%x, x) : y; }
ll lcm(ll x, ll y) { return (y / gcd(x, y))*x; }

int main() {
	//cout << fixed << setprecision(8);

	int n;
	float num[100005], dp[100005], ans;
	while (cin >> n) {
		dp[0] = 0;
		for (int a = 1; a <= n; a++)
			cin >> num[a];
		for (int a = 1; a <= n; a++)
			dp[a] = num[a] * (1 + dp[a - 1]);
		ans = 0;
		for (int a = 1; a <= n; a++)
			ans += num[a] * (dp[a-1] * 2 + 1);
		cout << ans << endl;
	}
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	double *p = new double[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i+1];
	}
	double *pr = new double[n + 1];
	double *dp = new double[n + 1];
	pr[0] = 0, dp[0] = 0;
	for (int i  = 1; i  <= n; ++i) {
		pr[i] = (pr[i - 1] + 1) * p[i];
		dp[i] = dp[i - 1] + (2 * pr[i - 1] + 1)*p[i];
	}
	cout.precision(15);
	cout << dp[n];

}


#include <iostream>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	double *p = new double[n + 1];
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i+1];
	}
	double *pr = new double[n + 1];
	double *dp = new double[n + 1];
	pr[0] = 0, dp[0] = 0;
	for (int i  = 1; i  <= n; ++i) {
		pr[i] = (pr[i - 1] + 1) * p[i];
		dp[i] = dp[i - 1] + (2 * pr[i - 1] + 1)*p[i];
	}
	cout.precision(15);
	cout << dp[n];

}


#include <iostream>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	double *p = new double[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i+1];
	}
	double *pr = new double[n + 1];
	double *dp = new double[n + 1];
	pr[0] = 0, dp[0] = 0;
	for (int i  = 1; i  <= n; ++i) {
		pr[i] = (pr[i - 1] + 1) * p[i];
		dp[i] = dp[i - 1] + (2 * pr[i - 1] + 1)*p[i];
	}
	cout << dp[n];

}


//----------------------JUGNU:LET YOUR LIGHT SHINE---------------------------//
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pf push_front
#define sz size
#define mk make_pair
#define ln length
#define fr(i,a,b) for(i=a;i<b;i++)
#define fre(i,a,b) for(i=a;i<=b;i++)
#define frr(i,a,b) for(i=a;i>=b;i--)
#define sc(a) scanf("%d", &a)
#define sm(a, b) scanf("%d%d", &a, &b)
#define pr(a) printf("%d\n", a)
#define prm(a, b) printf("%d %d\n", a, b)
#define cn(a) cin >> a
#define cm(a, b) cin >> a >> b
#define ct(a) cout << a << endl
#define ctm(a, b) cout << a << " " << b << endl
#define isset(x,i) ((x>>i)&1)
#define MAXN 100005
#define MOD 1000000007LL
#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);

#define trace1(x)       cerr << #x << " : " << x << endl;
#define trace2(x, y)    cerr << #x << " : " << x << " | " << #y << " : " << y << endl;
#define trace3(x, y, z) cerr << #x << " : " << x << " | " << #y << " : " << y << " | " << #z << " : " << z << endl;
#define cline cout << "----------------------" << endl;
using namespace std;
double nums[MAXN], expected[MAXN];
int main()
{
	int i, j, t, n, m, k, l, r, temp, mini, maxi, flag, result, cnt;
	sc(n);
	fre(i, 1, n) scanf("%lf", &nums[i]);
	expected[1] = nums[1];
	fre(i, 2, n){
		double prob = 1.00000;
		frr(j, i - 1, 0){
			expected[i] = expected[i] + expected[j] * prob * (1.0000 - nums[j + 1]);
			expected[i] = expected[i] + (i - j - 1) * (i - j - 1) * prob * (1.0000 - nums[j + 1]);
			prob *= nums[j + 1];
		}
		expected[i] = expected[i] + i * i * prob;
	}
	printf("%.8lf\n", expected[n]);
return 0;
}


//----------------------JUGNU:LET YOUR LIGHT SHINE---------------------------//
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pf push_front
#define sz size
#define mk make_pair
#define ln length
#define fr(i,a,b) for(i=a;i<b;i++)
#define fre(i,a,b) for(i=a;i<=b;i++)
#define frr(i,a,b) for(i=a;i>=b;i--)
#define sc(a) scanf("%d", &a)
#define sm(a, b) scanf("%d%d", &a, &b)
#define pr(a) printf("%d\n", a)
#define prm(a, b) printf("%d %d\n", a, b)
#define cn(a) cin >> a
#define cm(a, b) cin >> a >> b
#define ct(a) cout << a << endl
#define ctm(a, b) cout << a << " " << b << endl
#define isset(x,i) ((x>>i)&1)
#define MAXN 100005
#define MOD 1000000007LL
#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);

#define trace1(x)       cerr << #x << " : " << x << endl;
#define trace2(x, y)    cerr << #x << " : " << x << " | " << #y << " : " << y << endl;
#define trace3(x, y, z) cerr << #x << " : " << x << " | " << #y << " : " << y << " | " << #z << " : " << z << endl;
#define cline cout << "----------------------" << endl;
using namespace std;
double nums[MAXN], dp[MAXN], result = 0.000000, temp = 0.000000;
int main()
{
	int i, j, t, n, m, k, l, r, mini, maxi, flag, cnt;
	sc(n);
	fre(i, 1, n){
		scanf("%lf", &nums[i]);
		result += nums[i];
	}
	dp[1] = 0.00000;
	fre(i, 2, n){
		dp[i] = (dp[i-1] + nums[i-1]) * nums[i];
		temp += dp[i];
	}
	printf("%.8lf\n", result + 2.0000 * temp);
return 0;
}


#include<string.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<map>
#include<queue>
#include<set>
using namespace std;
typedef  long long int64;
typedef pair<int, int> PII;
typedef pair<PII, int> PLII;
typedef pair<double, PII> PDII;
typedef pair<double ,double> PDD;
#define DEBUG(a) cout<<#a"==="<<(a)<<endl;
const int MAXN = 100005;
double dp[MAXN][2];
double g[MAXN][2];
double p[MAXN];
int main() {
#ifdef TIOPLATO
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
    int n;
    while(scanf("%d", &n) == 1) {
        for(int i = 1; i <= n; i++) scanf("%lf", &p[i]);
        double sumdp, sum, sumk, sumk2, mul;
        mul = 1.0;
        memset(dp, 0, sizeof(dp));
        memset(g, 0, sizeof(g));
        dp[0][0] = 0; dp[0][1] = 0;
        g[0][0] = 1; g[0][1] = 0;
        sumdp = dp[0][0] / mul;
        sum = g[0][0] / mul;
        sumk = 0;
        sumk2 = 0;
        for(int i = 1; i <= n; i++) {
            mul *= p[i];
            dp[i][0] = (dp[i-1][0] + dp[i-1][1]) *(1.0 - p[i]);
            dp[i][1] = mul * (sumdp + sum * i * i - sumk * 2 * i +sumk2);
            g[i][0] = (g[i-1][0] + g[i-1][1]) *(1.0 - p[i]);
            g[i][1] = (g[i-1][0] + g[i-1][1]) * p[i];
            if(mul < 1e-10) continue;
            sumdp += dp[i][0]/mul;
            sum += g[i][0]/mul;
            sumk += g[i][0] * i / mul;
            sumk2 += g[i][0] * i * i / mul;

        }
        printf("%.15lf\n", dp[n][0] + dp[n][1]);
    }
}


#include <cstdio>
#include <algorithm>

using namespace std;

const int MAXN = 100100;

int main() {
  int n;
  double p, x, y;

  scanf("%d", &n);
  x = 0;
  y = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%lf", &p);
    y += (x + 1) * p;
    x = (x + 2) * p;
  }
  printf("%.10lf\n", y);

  return 0;
}


#include<string.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<map>
#include<queue>
#include<set>
using namespace std;
typedef  long long int64;
typedef pair<int, int> PII;
typedef pair<PII, int> PLII;
typedef pair<double, PII> PDII;
typedef pair<double ,double> PDD;
#define DEBUG(a) cout<<#a"==="<<(a)<<endl;
const int MAXN = 100005;
double dp[MAXN][2];
double g[MAXN][2];
double p[MAXN];
int main() {
#ifdef TIOPLATO
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	int n;
	while(scanf("%d", &n) == 1) {
		for(int i = 1; i <= n; i++) scanf("%lf", &p[i]);
		double sumdp, sum, sumk, sumk2, mul;
		mul = 1.0;
		memset(dp, 0, sizeof(dp));
		memset(g, 0, sizeof(g));
		dp[0][0] = 0; dp[0][1] = 0;
		g[0][0] = 1; g[0][1] = 0;
		sumdp = dp[0][0] / mul;
		sum = g[0][0] / mul;
		sumk = 0;
		sumk2 = 0;
		for(int i = 1; i <= n; i++) {
			mul *= p[i];
			dp[i][0] = (dp[i-1][0] + dp[i-1][1]) *(1.0 - p[i]);
			dp[i][1] = mul * (sumdp + sum * i * i - sumk * 2 * i +sumk2);
			g[i][0] = (g[i-1][0] + g[i-1][1]) *(1.0 - p[i]);
			g[i][1] = (g[i-1][0] + g[i-1][1]) * p[i];

			sumdp += dp[i][0]/mul;
			sum += g[i][0]/mul;
			sumk += g[i][0] * i / mul;
			sumk2 += g[i][0] * i * i / mul;
	/*	    DEBUG(dp[i][0]);
			DEBUG(dp[i][1]);
			DEBUG(g[i][0]);
			DEBUG(g[i][1]);*/

		}
		printf("%.10lf\n", dp[n][0] + dp[n][1]);
	}
}


// Artur Kraska, II UWr

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <list>
#include <set>
#include <map>

#define znak(z)                     ((z) <= '9' ? (z)-'0' : (z) - 'A'+10)
#define forr(it, lim)               for(int it=0; it < lim; it++)
#define foreach(iter, coll)         for(typeof(coll.begin()) iter = coll.begin(); iter != coll.end(); ++iter)
#define foreachr(iter, coll)        for(typeof(coll.rbegin()) iter = coll.rbegin(); iter != coll.rend(); ++iter)
#define lbound(P,R,PRED)            ({typeof(P) X=P,RRR=(R), PPP = P; while(PPP<RRR) {X = (PPP+(RRR-PPP)/2); if(PRED) RRR = X; else PPP = X+1;} PPP;})
#define clear(TABB)                 memset(TABB, 0, sizeof(TABB));

#define M 1000000007

using namespace std;

int n;

#define vv(type, name, ...)             type name ## 77[] = { __VA_ARGS__ }; vector <type> name(name ## 77, (name ## 77)+sizeof(name ## 77)/sizeof(name ## 77[0]));

int main()
{
    double wynik=0, diff=0, suma=0, last = 0.0, p=0;

    cin >> n;
    forr(i, n)
    {
        cin >> p;

        suma = (suma + diff)*p + (1.0-last)*p;

        diff = diff*p + 2*(1.0-last)*p;

        wynik += suma;

        last = p;

//        cout << i << ": " << wynik << endl;
    }

    printf("%.9f\n", wynik);

	return 0;
}


// Artur Kraska, II UWr

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <list>
#include <set>
#include <map>

#define znak(z)                     ((z) <= '9' ? (z)-'0' : (z) - 'A'+10)
#define forr(it, lim)               for(int it=0; it < lim; it++)
#define foreach(iter, coll)         for(typeof(coll.begin()) iter = coll.begin(); iter != coll.end(); ++iter)
#define foreachr(iter, coll)        for(typeof(coll.rbegin()) iter = coll.rbegin(); iter != coll.rend(); ++iter)
#define lbound(P,R,PRED)            ({typeof(P) X=P,RRR=(R), PPP = P; while(PPP<RRR) {X = (PPP+(RRR-PPP)/2); if(PRED) RRR = X; else PPP = X+1;} PPP;})
#define clear(TABB)                 memset(TABB, 0, sizeof(TABB));

#define M 1000000007

using namespace std;

int n;

#define vv(type, name, ...)             type name ## 77[] = { __VA_ARGS__ }; vector <type> name(name ## 77, (name ## 77)+sizeof(name ## 77)/sizeof(name ## 77[0]));

int main()
{
    double wynik, diff, suma, last = 0.0, p;

    cin >> n;
    forr(i, n)
    {
        cin >> p;

        suma = (suma + diff)*p + (1.0-last)*p;

        diff = diff*p + 2*(1.0-last)*p;

        wynik += suma;

        last = p;

//        cout << i << ": " << wynik << endl;
    }

    printf("%.9f\n", wynik);

	return 0;
}


// Artur Kraska, II UWr

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <list>
#include <set>
#include <map>

#define znak(z)                     ((z) <= '9' ? (z)-'0' : (z) - 'A'+10)
#define forr(it, lim)               for(int it=0; it < lim; it++)
#define foreach(iter, coll)         for(typeof(coll.begin()) iter = coll.begin(); iter != coll.end(); ++iter)
#define foreachr(iter, coll)        for(typeof(coll.rbegin()) iter = coll.rbegin(); iter != coll.rend(); ++iter)
#define lbound(P,R,PRED)            ({typeof(P) X=P,RRR=(R), PPP = P; while(PPP<RRR) {X = (PPP+(RRR-PPP)/2); if(PRED) RRR = X; else PPP = X+1;} PPP;})
#define clear(TABB)                 memset(TABB, 0, sizeof(TABB));

#define M 1000000007

using namespace std;

int n, k, tab[1000007];

#define vv(type, name, ...)             type name ## 77[] = { __VA_ARGS__ }; vector <type> name(name ## 77, (name ## 77)+sizeof(name ## 77)/sizeof(name ## 77[0]));

int main()
{
    double wynik, diff, suma, last = 0.0, p;

    scanf("%d", &n);
    forr(i, n)
    {
        cin >> p;

        suma = (suma + diff)*p + (1.0-last)*p;

        diff = diff*p + 2*(1.0-last)*p;

        wynik += suma;

        last = p;

//        cout << i << ": " << wynik << endl;
    }

    printf("%.9f\n", wynik);

	return 0;
}


// Artur Kraska, II UWr

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <list>
#include <set>
#include <map>

#define znak(z)                     ((z) <= '9' ? (z)-'0' : (z) - 'A'+10)
#define forr(it, lim)               for(int it=0; it < lim; it++)
#define foreach(iter, coll)         for(typeof(coll.begin()) iter = coll.begin(); iter != coll.end(); ++iter)
#define foreachr(iter, coll)        for(typeof(coll.rbegin()) iter = coll.rbegin(); iter != coll.rend(); ++iter)
#define lbound(P,R,PRED)            ({typeof(P) X=P,RRR=(R), PPP = P; while(PPP<RRR) {X = (PPP+(RRR-PPP)/2); if(PRED) RRR = X; else PPP = X+1;} PPP;})
#define clear(TABB)                 memset(TABB, 0, sizeof(TABB));

#define M 1000000007

using namespace std;

int n;

#define vv(type, name, ...)             type name ## 77[] = { __VA_ARGS__ }; vector <type> name(name ## 77, (name ## 77)+sizeof(name ## 77)/sizeof(name ## 77[0]));

int main()
{
    double wynik, diff, suma, last = 0.0, p;

    cin >> n;
    forr(i, n)
    {
        cin >> p;

        suma = (suma + diff)*p + (1.0-last)*p;

        diff = diff*p + 2*(1.0-last)*p;

        wynik += suma;

        last = p;

//        cout << i << ": " << wynik << endl;
    }

    printf("%.9f\n", wynik);

    return 0;
}


// Artur Kraska, II UWr

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <list>
#include <set>
#include <map>

#define znak(z)                     ((z) <= '9' ? (z)-'0' : (z) - 'A'+10)
#define forr(it, lim)               for(int it=0; it < lim; it++)
#define foreach(iter, coll)         for(typeof(coll.begin()) iter = coll.begin(); iter != coll.end(); ++iter)
#define foreachr(iter, coll)        for(typeof(coll.rbegin()) iter = coll.rbegin(); iter != coll.rend(); ++iter)
#define lbound(P,R,PRED)            ({typeof(P) X=P,RRR=(R), PPP = P; while(PPP<RRR) {X = (PPP+(RRR-PPP)/2); if(PRED) RRR = X; else PPP = X+1;} PPP;})
#define clear(TABB)                 memset(TABB, 0, sizeof(TABB));

#define M 1000000007

using namespace std;

int n, k, tab[1000007];

#define vv(type, name, ...)             type name ## 77[] = { __VA_ARGS__ }; vector <type> name(name ## 77, (name ## 77)+sizeof(name ## 77)/sizeof(name ## 77[0]));

int main()
{
    double wynik, diff, suma, last = 0.0, p;

    scanf("%d", &n);
    forr(i, n)
    {
        cin >> p;

        suma = (suma + diff)*p + (1.0-last)*p;

        diff = diff*p + 2*(1.0-last)*p;

        wynik += suma;

        last = p;

//        cout << i << ": " << wynik << endl;
    }

    cout << wynik << endl;

	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
const int NN=111111;
double f[NN];
double dp[NN];
int main(){
#ifndef ONLINE_JUDGE
	freopen("/home/rainto96/in.txt","r",stdin);
#endif

	int n;scanf("%d",&n);
	double sum=0;
	for(int i=1;i<=n;i++){
		//cin>>f[i];
		scanf("%lf",&f[i]);
		sum+=f[i];
	}
	double ansum=0;
	for(int i=2;i<=n;i++){
		dp[i]=(dp[i-1]+f[i-1])*f[i];
		ansum+=dp[i];
	}
	//cout<<ansum*2.0+sum<<endl;
	printf("%f\n",ansum*2.0+sum);
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
const int NN=111111;
double f[NN];
double dp[NN];
int main(){
#ifndef ONLINE_JUDGE
	freopen("/home/rainto96/in.txt","r",stdin);
#endif

	int n;cin>>n;
	double sum=0;
	for(int i=1;i<=n;i++){
		cin>>f[i];
		sum+=f[i];
	}
	double ansum=0;
	for(int i=2;i<=n;i++){
		dp[i]=(dp[i-1]+f[i-1])*f[i];
		ansum+=dp[i];
	}
	cout<<ansum*2+sum<<endl;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
const int NN=111111;
double f[NN];
double dp[NN];
int main(){
	int n;cin>>n;
	double sum=0;
	for(int i=1;i<=n;i++){
		cin>>f[i];
		sum+=f[i];
	}
	for(int i=2;i<=n;i++){
		dp[i]=(dp[i-1]+f[i-1])*f[i];
	}
	cout<<dp[n]*2+sum<<endl;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
const int NN=111111;
double f[NN];
double dp[NN];
int main(){
#ifndef ONLINE_JUDGE
	freopen("/home/rainto96/in.txt","r",stdin);
#endif

	int n;scanf("%d",&n);
	double sum=0;
	for(int i=1;i<=n;i++){
		//cin>>f[i];
		scanf("%lf",&f[i]);
		sum+=f[i];
	}
	double ansum=0;
	for(int i=2;i<=n;i++){
		dp[i]=(dp[i-1]+f[i-1])*f[i];
		ansum+=dp[i];
	}
	cout.precision(15);
	cout<<ansum*2.0+sum<<endl;
	//printf("%f\n",ansum*2.0+sum);
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
const int NN=111111;
double f[NN];
double dp[NN];
int main(){
	int n;cin>>n;
	double sum=0;
	for(int i=1;i<=n;i++){
		cin>>f[i];
		sum+=f[i];
	}
	for(int i=2;i<=n;i++){
		dp[i]=(dp[i-1]+f[i-1])*f[i];
	}
	cout<<dp[i]*2+sum<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define l 100100
int n;
long double p[l],dp[l],sum=0,sol=0;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
        sum+=p[i];
    }
    sol=sum;
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=(dp[i-1]+p[i-1])*p[i];
        sol+=2*dp[i];
    }
    cout<<setprecision(10)<<sol;
    return 0;
}


#include <iostream>
#define l 100100
using namespace std;
int n;
long double p[l],dp[l],sum=0,sol=0;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
        sum+=p[i];
    }
    sol=sum;
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=(dp[i-1]+p[i-1])*p[i];
        sol+=2*dp[i];
    }
    cout<<setprecision(10)<<sol;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define SIZE 2010

int pfx[SIZE];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int caseNum; cin >> caseNum;
    while (caseNum--) {
        int len, expt; string str;
        cin >> len >> expt >> str;
        const auto trans = [](char ch) { return ch == '(' ? 1 : -1; };
        for (int i = 0; i < len; i++)
            pfx[i] = trans(str[i]);
        int cnt = 0;
        for (int i = 1; i < len; i++)
            pfx[i] += pfx[i - 1], cnt += (pfx[i] == 0);

        vector<pair<int, int> > v;
        if (cnt == expt) {
            cout << 0 << '\n';
            continue;
        } else if (cnt > expt) {
            // Reduce the number of 0
            while (cnt > expt) {
                for (int i = len - 2; i >= 0; i--) {
                    if (pfx[i] == 0) {
                        int dfst = -trans(str[i]) * 2;
                        int dsnd = dfst - trans(str[i + 1]) * 2;
                        if (pfx[i] + dfst == 0 || pfx[i + 1] + dsnd == 0)
                            continue;
                        pfx[i] += dfst; pfx[i + 1] += dsnd;
                        swap(str[i], str[i + 1]); cnt--;
                        v.push_back(make_pair(i + 1, i + 2));
                        for (int j = i + 2; j < len; j++)
                            pfx[j] += dsnd;
                        break;
                    }
                }
            }

            cout << v.size() << '\n';
            for (const auto & p : v)
                cout << p.first << ' ' << p.second << '\n';
        } else {
            // Increase the number of 0
            while (cnt < expt) {
                for (int i = len - 2; i >= 0; i--) {
                    if (pfx[i] != 0 && pfx[i + 1] != 0) {
                        int dfst = -trans(str[i]) * 2;
                        int dsnd = dfst - trans(str[i + 1]) * 2;

                        if (pfx[i] + dfst == 0 || pfx[i + 1] + dsnd == 0) {
                            pfx[i] += dfst; pfx[i + 1] += dsnd;
                            swap(str[i], str[i + 1]); cnt++;
                            v.push_back(make_pair(i + 1, i + 2));
                            for (int j = i + 2; j < len; j++)
                                pfx[j] += dsnd;
                            break;
                        }
                    }
                }
            }

            cout << v.size() << '\n';
            for (const auto & p : v)
                cout << p.first << ' ' << p.second << '\n';
        }
    }

    return 0;
}


#include <iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (t;t > 0;--t)
	{
		int n, k;
		cin >> n >> k;

		string skobki;
		cin >> skobki;

		long long changes = 0;
		vector<pair<int, int> > change;

		for (int i = 0;i < n;++i)
		{
			if (k > 0)
			{
				if (skobki[i] == ')')
				{
					for (int j = i;j < n;++j)
					{
						if (skobki[j] == '(')
						{
							swap(skobki[i], skobki[j]);
							changes++;
							change.push_back({ i + 1,j + 1 });
							break;
						}
					}
				}
				--k;
			}
			else
			{
				if (skobki[i] == '(')
				{
					for (int j = i;j < n;++j)
					{
						if (skobki[j] == ')')
						{
							swap(skobki[i], skobki[j]);
							changes++;
							change.push_back({ i ,j });
							break;
						}
					}
				}
			}

		}
		cout << changes << endl;
		//cout << endl << skobki << endl;
		for (int i = 0;i < changes;++i)
		{
			cout << change[i].first << " " << change[i].second << endl;
		}
	}

}


#include <iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (t;t > 0;--t)
	{
		int n, k;
		cin >> n >> k;

		string skobki;
		cin >> skobki;

		long long changes = 0;
		vector<pair<int, int> > change;

		for (int i = 0;i < n;++i)
		{
			if (skobki[i] == ')')
			{
				for (int j = i;j < n;++j)
				{
					if (skobki[j] == '(')
					{
						swap(skobki[i], skobki[j]);
						changes++;
						change.push_back({ i + 1,j + 1 });
					}
				}
			}
			else
			{
				--k;
			}
			if (k == 0)
				break;
		}
		cout << changes << endl;
		for (int i = 0;i < changes;++i)
		{
			cout << change[i].first << " " << change[i].second << endl;
		}
	}

}


#include <iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (t;t > 0;--t)
	{
		int n, k;
		cin >> n >> k;

		string skobki;
		cin >> skobki;

		long long changes = 0;
		vector<pair<int, int> > change;

		for (int i = 0;i < n;++i)
		{
			if (k > 0)
			{
				if (skobki[i] == ')')
				{
					for (int j = i;j < n;++j)
					{
						if (skobki[j] == '(')
						{
							swap(skobki[i], skobki[j]);
							changes++;
							change.push_back({ i + 1,j + 1 });
						}
					}
				}
				else
				{
					--k;
				}
			}
			else
			{
				if (skobki[i] == '(')
				{
					for (int j = i;j < n;++j)
					{
						if (skobki[j] == ')')
						{
							swap(skobki[i], skobki[j]);
							changes++;
							change.push_back({ i ,j });
						}
					}
				}
			}

		}
		cout << changes << endl;
		for (int i = 0;i < changes;++i)
		{
			cout << change[i].first << " " << change[i].second << endl;
		}
	}

}


#include <iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (t;t > 0;--t)
	{
		int n, k;
		cin >> n >> k;

		string skobki;
		cin >> skobki;

		long long changes = 0;
		vector<pair<int, int> > change;

		for (int i = 0;i < n;++i)
		{
			if (k > 0)
			{
				if (skobki[i] == ')')
				{
					for (int j = i;j < n;++j)
					{
						if (skobki[j] == '(')
						{
							int h = j;
							change.push_back({ i,j });
							++changes;
							for (int d = i;d <= (i + j) / 2;++d)
							{
								swap(skobki[d], skobki[h]);
								--h;
							}
							break;
						}
					}
				}
				--k;
			}
			else
			{
				if (skobki[i] == '(')
				{
					for (int j = i;j < n;++j)
					{
						if (skobki[j] == ')')
						{
							int h = j;
							change.push_back({ i,j });
							++changes;
							for (int d = i;d <= (i + j) / 2;++d)
							{
								swap(skobki[d], skobki[h]);
								--h;
							}
							break;
						}
					}
				}
			}

		}
		cout << changes << endl;
		//cout << endl << skobki << endl;
		for (int i = 0;i < changes;++i)
		{
			cout << change[i].first << " " << change[i].second << endl;
		}
	}

}


#include <iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (t;t > 0;--t)
	{
		int n, k;
		cin >> n >> k;

		string skobki;
		cin >> skobki;

		long long changes = 0;
		vector<pair<int, int> > change;

		for (int i = 0;i < n;++i)
		{
			if (k > 0)
			{
				if (skobki[i] == ')')
				{
					for (int j = i;j < n;++j)
					{
						if (skobki[j] == '(')
						{
							swap(skobki[i], skobki[j]);
							changes++;
							change.push_back({ i + 1,j + 1 });
						}
					}
				}
				else
				{
					--k;
				}
			}
			else
			{
				if (skobki[i] == '(')
				{
					for (int j = i;j < n;++j)
					{
						if (skobki[j] == ')')
						{
							swap(skobki[i], skobki[j]);
							changes++;
							change.push_back({ i + 1,j + 1 });
						}
					}
				}
			}

		}
		cout << changes << endl;
		for (int i = 0;i < changes;++i)
		{
			cout << change[i].first << " " << change[i].second << endl;
		}
	}

}


#include <iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (t;t > 0;--t)
	{
		int n, k;
		cin >> n >> k;

		string skobki;
		cin >> skobki;

		long long changes = 0;
		vector<pair<int, int> > change;

		for (int i = 0;i < n;++i)
		{
			if (k > 0)
			{
				if (skobki[i] == '(')
				{
					//++i;
					if (skobki[i + 1] == '(')
					{
						//--i;
						for (int j = i+1;j < n;++j)
						{
							if (skobki[j] == ')')
							{
								change.push_back({ i+2,j+1 });
								++changes;
								int h = j;
								for (int d = i+1;d <= (i + j) / 2;++d)
								{
									swap(skobki[d], skobki[h]);
									--h;
								}
								++i;
								break;

							}
						}
					}
					else
						++i;
				}
				else
				{
					for (int j = i + 1;j < n;++j)
					{
						if (skobki[j] == '(')
						{
							change.push_back({ i+1,j+1 });
							++changes;
							int h = j;
							for (int d = i;d <= (i + j) / 2;++d)
							{
								swap(skobki[d], skobki[h]);
								--h;
							}
							++i;
							break;

						}
					}
				}
				--k;
				/*if (k == 0)
					--i;*/
			}
			else
			{
				if (skobki[i] == ')')
					continue;
				else
				{
					for (int j = i;j < n;++j)
					{
						if (skobki[j] == ')')
						{
							change.push_back({ i+1,j+1 });
							++changes;
							int h = j;
							for (int d = i;d <= (i + j) / 2;++d)
							{
								swap(skobki[d], skobki[h]);
								--h;
							}
							++i;
							break;

						}
					}
				}
			}

		}
		//cout << endl;
		cout << changes << endl;
		//cout << skobki << endl;
		for (int i = 0;i < changes;++i)
		{
			cout << change[i].first << " " << change[i].second << endl;
		}
		//cout << endl;
	}

}


#include <iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (t;t > 0;--t)
	{
		int n, k;
		cin >> n >> k;

		string skobki;
		cin >> skobki;
		--k;
		long long change = 0;
		vector<pair<int, int> > changes;

		for (int i = 0;i < n;++i)
		{
			int need = 0;
			if (i < 2 * k)
			{
				need = i % 2;
			}
			else if (i < (2 * k + n) / 2)
			{
				need = 0;
			}
			else
				need = 1;

			int cur = 0;

			cur = skobki[i] == '(' ? 0 : 1;

			if (cur != need)
			{
				int j;
				for (j = i + 1;j < n;++j)
				{
					int cur2 = skobki[j] == '(' ? 0 : 1;
					if (cur2 == need)
						break;
				}
				changes.push_back({ i,j });
				change++;
				for (int ii = 0; ii < (j - i + 1) / 2; ii++)
				{
					swap(skobki[i + ii], skobki[j - ii]);
				}
			}
		}

		cout << change << endl;
		for (int i = 0;i < change;++i)
		{
			cout << changes[i].first + 1 << " " << changes[i].second + 1 << endl;
		}
	}

}


#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
void revers(int l, int r, string& a) {
	string q;
	for (int i = l; i <= r; ++i) {
		q.push_back(a[i]);
	}
	reverse(q.begin(), a.end());
	for (int i = l; i <= r; ++i) {
		a[i] = q[i - l];
	}
}
int main() {
	int tt;
	cin >> tt;
	while (tt--) {
		int n;
		cin >> n;
		int k;
		cin >> k;
		string s;
		cin >> s;
		string t = "";
		for (int i = 0; i < k - 1; ++i) {
			t += "()";
		}
		int x = n - t.size();
		for (int i = 0; i < x; ++i) t += "(";
		for (int i = 0; i < x; ++i) t += ")";
		vector<pair<int,int>> ans;
		for (int i = 0; i < n; ++i) {
			if (s[i] == t[i]) continue;
			int j0 = 0;
			for (int j = i + 1; j < n; ++j) {
				if (s[i] != t[j]) j0 = j;
			}
			ans.push_back({ i + 1,j0 + 1 });
			revers(i, j0, s);
		}
		cout << ans.size() << endl;
		for (auto elem : ans) cout << elem.first << ' ' << elem.second << endl;
	}
}


#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
void revers(int l, int r, string& a) {
	string q;
	for (int i = l; i <= r; ++i) {
		q.push_back(a[i]);
	}
	reverse(q.begin(), q.end());
	for (int i = l; i <= r; ++i) {
		a[i] = q[i - l];
	}
}
int main() {
	int tt;
	cin >> tt;
	while (tt--) {
		int n;
		cin >> n;
		int k;
		cin >> k;
		string s;
		cin >> s;
		string t = "";
		for (int i = 0; i < k - 1; ++i) {
			t += "()";
			//cout << "YES\n";
		}
		int x = n - t.size();
		for (int i = 0; i < x / 2; ++i) t += "(";
		for (int i = 0; i < x / 2; ++i) t += ")";
		vector<pair<int,int>> ans;
		//cout << t << endl;
		for (int i = 0; i < n; ++i) {
			if (s[i] == t[i]) continue;
			int j0 = 0;
			for (int j = i + 1; j < n; ++j) {
				if (s[i] != t[j]) j0 = j;
			}
			ans.push_back({ i + 1,j0 + 1 });
			revers(i, j0, s);
		}
		cout << ans.size() << endl;
		for (auto elem : ans) cout << elem.first << ' ' << elem.second << endl;
	}
}


#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
void revers(int l, int r, string& a) {
	string q;
	for (int i = l; i <= r; ++i) {
		q.push_back(a[i]);
	}
	reverse(q.begin(), q.end());
	for (int i = l; i <= r; ++i) {
		a[i] = q[i - l];
	}
}
int main() {
	int tt;
	cin >> tt;
	while (tt--) {
		int n;
		cin >> n;
		int k;
		cin >> k;
		string s;
		cin >> s;
		string t = "";
		for (int i = 0; i < k - 1; ++i) {
			t += "()";
			//cout << "YES\n";
		}
		int x = n - t.size();
		for (int i = 0; i < x / 2; ++i) t += "(";
		for (int i = 0; i < x / 2; ++i) t += ")";
		vector<pair<int,int>> ans;
		//cout << t << endl;
		for (int i = 0; i < n; ++i) {
			if (s[i] == t[i]) continue;
			int j0 = 0;
			for (int j = i + 1; j < n; ++j) {
				if (s[i] == t[j]) j0 = j;
			}
			ans.push_back({ i + 1,j0 + 1 });
			revers(i, j0, s);
		}
		cout << ans.size() << endl;
		for (auto elem : ans) cout << elem.first << ' ' << elem.second << endl;
	}
}


#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
void revers(int l, int r, string& a) {
	string q;
	for (int i = l; i <= r; ++i) {
		q.push_back(a[i]);
	}
	reverse(q.begin(), q.end());
	for (int i = l; i <= r; ++i) {
		a[i] = q[i - l];
	}
}
int main() {
	int tt;
	cin >> tt;
	while (tt--) {
		int n, k;
		string s, t;
		cin >> n >> k >> s;
		int m = n / 2 - k + 1;
		t = "";
		while (--k) t += "()";
		for (int i = 0; i < m; ++i) t += "(";
		for (int i = 0; i < m; ++i) t += ")";
		vector <pair <int, int> > ans;
		for (int i = 0; i < n; ++i) if (s[i] != t[i]) {
			int j = i + 1;
			while (s[j] != t[i]) ++j;
			ans.push_back({ i + 1, j + 1 });
			int id = i;
			while (id < j) swap(s[id], s[j]), ++id, --j;
		}
		cout << ans.size();
		for (auto p : ans) cout << "\n" << p.first << " " << p.second;
		cout << "\n";
	}
}


#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
void revers(int l, int r, string& a) {
	string q;
	for (int i = l; i <= r; ++i) {
		q.push_back(a[i]);
	}
	reverse(q.begin(), q.end());
	for (int i = l; i <= r; ++i) {
		a[i] = q[i - l];
	}
}
int main() {
	int tt;
	cin >> tt;
	while (tt--) {
		int n, k;
		string s, t;
		cin >> n >> k >> s;
		int m = n / 2 - k + 1;
		t = "";
		while (--k) t += "()";
		for (int i = 0; i < m; ++i) t += "(";
		for (int i = 0; i < m; ++i) t += ")";
		vector <pair <int, int> > ans;
		for (int i = 0; i < n; ++i) if (s[i] != t[i]) {
			int j = i + 1;
			while (s[j] != t[i]) ++j;
			ans.push_back({ i + 1, j + 1 });
			int id = i;
			while (id < j) swap(s[id], s[j]), ++id, --j;
		}
		cout << ans.size();
		for (auto p : ans) cout << "\n" << p.first << " " << p.second;
	}
}


#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<ctime>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PI acos(-1)
#define lowbit(x) (x)&(-x)
const double eps = 1e-10;
const double Dlt = 0.97;
const int inf = 0x3f3f3f3f;
const ll INF = 1e18;
const int maxn = 2000 + 10;
const int maxm = 2000000 + 10;
const int mod = 1000000000 + 7;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll read()
{
	char ch = getchar(); ll x = 0, f = 1;
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while ('0' <= ch && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n, k;
char s[maxn];
int ansa[maxn], ansb[maxn];
int main() {
	int T = read();
	while (T--)
	{
		n = read(), k = read();
		scanf("%s", s + 1);
		int now=(k-1)*2;
		int len=0;
		for(int i=1;i<=now;++i){
			if(i&1){
				if(s[i]==')'){
					int j;
					for(j=i+1;j<=n;++j)if(s[j]=='(')break;
					++len;
					ansa[len]=i,ansb[len]=j;
					for(int k=i;k<=(j+i)/2;++k){
						swap(s[k],s[j-i+k]);
					}
				}
			}
			else{
				if(s[i]=='('){
					int j;
					for(j=i+1;j<=n;++j)if(s[j]==')')break;
					++len;
					ansa[len]=i,ansb[len]=j;
					for(int k=i;k<=(j+i)/2;++k){
						swap(s[k],s[j-i+k]);
					}
				}
			}
		}
		for(int i=now+1;i<=(now+1+n)/2;++i){
			if(s[i]==')'){
				int j;
				for(j=i+1;j<=n;++j)if(s[j]=='(')break;
				++len;
				ansa[len]=i,ansb[len]=j;
				for(int k=i;k<=(j+i)/2;++k){
					swap(s[k],s[j-i+k]);
				}
			}
		}
		printf("%d\n",len);
		for(int i=1;i<=len;++i){
			printf("%d %d\n",ansa[i],ansb[i]);
		}
	}
}


#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<ctime>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PI acos(-1)
#define lowbit(x) (x)&(-x)
const double eps = 1e-10;
const double Dlt = 0.97;
const int inf = 0x3f3f3f3f;
const ll INF = 1e18;
const int maxn = 2000 + 10;
const int maxm = 2000000 + 10;
const int mod = 1000000000 + 7;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll read()
{
	char ch = getchar(); ll x = 0, f = 1;
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while ('0' <= ch && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n, k;
char s[maxn];
int ansa[maxn], ansb[maxn];
int main() {
	int T = read();
	while (T--)
	{
		n = read(), k = read();
		scanf("%s", s + 1);
		int now=(k-1)*2;
		int len=0;
		for(int i=1;i<=now;++i){
			if(i&1){
				if(s[i]==')'){
					int j;
					for(j=i+1;j<=n;++j)if(s[j]=='(')break;
					++len;
					ansa[len]=i,ansb[len]=j;
					for(int k=i;k<=(j+i)/2;++k){
						swap(s[k],s[j-i+k]);
					}
				}
			}
			else{
				if(s[i]=='('){
					int j;
					for(j=i+1;j<=n;++j)if(s[j]==')')break;
					++len;
					ansa[len]=i,ansb[len]=j;
					for(int k=i;k<=(j+i)/2;++k){
						swap(s[k],s[j-i+k]);
					}
				}
			}
		}
		for(int i=now+1;i<=(now+1+n)/2;++i){

			if(s[i]==')'){
				//printf("%d\n",i);
				int j;
				for(j=n;j>i;--j)if(s[j]=='(')break;
				++len;
				ansa[len]=i,ansb[len]=j;
				//printf("%d %d\n",i,j);
				for(int k=i;k<=(j+i)/2;++k){
					swap(s[k],s[j-i+k]);
				}
			}
		}
		//printf("%s",s+1);
		printf("%d\n",len);
		for(int i=1;i<=len;++i){
			printf("%d %d\n",ansa[i],ansb[i]);
		}
	}
}


#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<ctime>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PI acos(-1)
#define lowbit(x) (x)&(-x)
const double eps = 1e-10;
const double Dlt = 0.97;
const int inf = 0x3f3f3f3f;
const ll INF = 1e18;
const int maxn = 2000 + 10;
const int maxm = 2000000 + 10;
const int mod = 1000000000 + 7;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll read()
{
	char ch = getchar(); ll x = 0, f = 1;
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while ('0' <= ch && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n, k;
char s[maxn];
int ansa[maxn], ansb[maxn];
int main() {
	int T = read();
	while (T--)
	{
		n = read(), k = read();
		scanf("%s", s + 1);
		int pos = 1;
		int len = 0;
		for (int i = 2; i <= n; ++i)
		{
			if (s[i - 1] == '('&&s[i] == ')')
			{
				pos = i + 1;
			}
			else if (s[i] == s[i - 1])continue;
			else
			{
				++len;
				ansa[len] = pos, ansb[len] = i;
				pos = i + 1;
			}
		}
		printf("%d\n", len);
		for (int i = 1; i <= len; ++i)
		{
			printf("%d %d\n", ansa[i], ansb[i]);
		}
	}
}


#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<ctime>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PI acos(-1)
#define lowbit(x) (x)&(-x)
const double eps = 1e-10;
const double Dlt = 0.97;
const int inf = 0x3f3f3f3f;
const ll INF = 1e18;
const int maxn = 2000 + 10;
const int maxm = 2000000 + 10;
const int mod = 1000000000 + 7;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll read()
{
	char ch = getchar(); ll x = 0, f = 1;
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while ('0' <= ch && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n, k;
char s[maxn];
int ansa[maxn], ansb[maxn];
int main() {
	int T = read();
	while (T--)
	{
		n = read(), k = read();
		scanf("%s", s + 1);
		int pos = 1;
		int len = 0;
		for (int i = 2; i <= n; ++i)
		{
			if (s[i - 1] == '('&&s[i] == ')')
			{
				pos = i + 1;
			}
			else if (s[i] == s[i - 1])continue;
			else
			{
				s[i] = s[pos];
				++len;
				ansa[len] = pos, ansb[len] = i;
				pos = i;
			}
		}
		printf("%d\n", len);
		for (int i = 1; i <= len; ++i)
		{
			printf("%d %d\n", ansa[i], ansb[i]);
		}
	}
}


#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<ctime>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PI acos(-1)
#define lowbit(x) (x)&(-x)
const double eps = 1e-10;
const double Dlt = 0.97;
const int inf = 0x3f3f3f3f;
const ll INF = 1e18;
const int maxn = 2000 + 10;
const int maxm = 2000000 + 10;
const int mod = 1000000000 + 7;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll read()
{
	char ch = getchar(); ll x = 0, f = 1;
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while ('0' <= ch && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n, k;
char s[maxn];
int ansa[maxn], ansb[maxn];
int main() {
	int T = read();
	while (T--)
	{
		n = read(), k = read();
		scanf("%s", s + 1);
		int now=(k-1)*2;
		int len=0;
		for(int i=1;i<=now;++i){
			if(i&1){
				if(s[i]==')'){
					int j;
					for(j=i+1;j<=n;++j)if(s[j]=='(')break;
					++len;
					ansa[len]=i,ansb[len]=j;
					for(int k=0;k<(j-i+1)/2;++k)
						swap(s[i+k],s[j-k]);
				}
			}
			else{
				if(s[i]=='('){
					int j;
					for(j=i+1;j<=n;++j)if(s[j]==')')break;
					++len;
					ansa[len]=i,ansb[len]=j;
					for(int k=0;k<(j-i+1)/2;++k)
						swap(s[i+k],s[j-k]);
				}
			}
		}
		for(int i=now+1;i<=(now+1+n)/2;++i){

			if(s[i]==')'){
				//printf("%d\n",i);
				int j;
				for(j=n;j>i;--j)if(s[j]=='(')break;
				++len;
				ansa[len]=i,ansb[len]=j;
				//printf("%d %d\n",i,j);
				for(int k=0;k<(j-i+1)/2;++k)
						swap(s[i+k],s[j-k]);
			}
		}
		//printf("%s",s+1);
		printf("%d\n",len);
		for(int i=1;i<=len;++i){
			printf("%d %d\n",ansa[i],ansb[i]);
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define pii pair<ll,ll>
#define ppi pair<pii,ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    int n,t,k,i,j;
    cin>>t;
    string s,temp;
    while(t--){
        vector<pii>ans;
        cin>>n>>k;
        cin>>s;

        stack<char>par;

        for(i=0;i<n;i++){
            if(s[i]=='('){
                for(j=i+1;j<n;j++){
                    if(s[j]==')'){
                        if(j==i+1){
                            i++;
                            break;
                        }
                        i++;
                        reverse(s.begin()+i,s.begin()+j+1);
                        ans.push_back(make_pair(i+1,j+1));
                        break;
                    }
                }
            }
            else{
                for(j=i+1;j<n;j++){
                    if(s[j]=='('){
                        reverse(s.begin()+i,s.begin()+j+1);
                        ans.push_back(make_pair(i+1,j+1));
                        i++;
                        break;
                    }
                }
            }
        }
        //cout<<s<<endl;
        j=n/2;
        for(i=2;i<n;i+=2){
            if(j==k)break;
            reverse(s.begin()+i-1,s.begin()+i+1);
            ans.push_back(make_pair(i,i+1));
            j--;
        }
        cout<<s<<endl;
        cout<<ans.size()<<endl;
        for(i=0;i<ans.size();i++){
            cout<<ans[i].first<<" "<<ans[i].second<<endl;
        }

    }

    return 0;
}
/*
1
10 5
((((()))))
*/


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define pii pair<ll,ll>
#define ppi pair<pii,ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    int n,t,k,i,j;
    cin>>t;
    string s,temp;
    while(t--){
        vector<pii>ans;
        cin>>n>>k;
        cin>>s;
        int o,c;
        c=o=0;
        int cnt=k,st;
        st=0;
        stack<char>par;

        for(i=0;i<n;i++){
            if(s[i]=='(')
                par.push('(');
            else if(!par.empty()){
                par.pop();
            }
            else{
                for(j=i;j<n;j++){
                    if(s[j]=='(')o++;
                    else c++;
                    if(o==c){
                        reverse(s.begin()+i,s.begin()+j+1);
                        ans.push_back(make_pair(i+1,j+1));
                        i=j;
                        break;
                    }
                }
            }
        }
        while(!par.empty()){
            par.pop();
        }
        j=1;
        int l=n/2;
        for(i=0;;i++){
            if(i==n){
                j=1;
                i=0;
                while(!par.empty())par.pop();
            }
            if(s[i]=='(')par.push(s[i]);
            else{
                par.pop();
                if(par.empty()){
                     if(i==n-1)continue;
                    j++;
                }
                else{
                    if(par.size()==1){
                        j++;
                    }
                    reverse(s.begin()+i-1,s.begin()+i+1);
                    ans.push_back(make_pair(i,i+1));

                }
            }
            //cout<<j<<" "<<i<<endl;
            if(j==l)break;
        }
        j=0;

        for(i=0;i<n;i++){
            if(s[i]=='(')par.push(s[i]);
            else par.pop();
            if(par.empty())j++;
            if(j>k){
                j--;
                reverse(s.begin()+i-2,s.begin()+i);
                ans.push_back(make_pair(i-1,i));
            }
        }

        cout<<ans.size()<<endl;
        for(i=0;i<ans.size();i++){
            cout<<ans[i].first<<" "<<ans[i].second<<endl;
        }

    }

    return 0;
}
/*
1
10 5
((((()))))
*/


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define pii pair<ll,ll>
#define ppi pair<pii,ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    int n,t,k,i,j;
    cin>>t;
    string s,temp;
    while(t--){
        vector<pii>ans;
        cin>>n>>k;
        cin>>s;
        int o,c;
        c=o=0;
        int cnt=k,st;
        st=0;
        stack<char>par;

        for(i=0;i<n;i++){
            if(s[i]=='(')
                par.push('(');
            else if(!par.empty()){
                par.pop();
            }
            else{
                for(j=i;j<n;j++){
                    if(s[j]=='(')o++;
                    else c++;
                    if(o==c){
                        reverse(s.begin()+i,s.begin()+j+1);
                        ans.push_back(make_pair(i+1,j+1));
                        i=j;
                        break;
                    }
                }
            }
        }
        while(!par.empty()){
            par.pop();
        }
        j=0;
       // cout<<s<<endl;

        for(i=0;i<n;i++){
            if(s[i]=='(')par.push(s[i]);
            else par.pop();
            if(par.empty())j++;
            if(j>k){
                j--;
                reverse(s.begin()+i-2,s.begin()+i);
                ans.push_back(make_pair(i-1,i));
            }
        }
        j=0;
        for(i=0;i<n;i++){
            if(s[i]=='(')par.push(s[i]);
            else par.pop();
            if(par.empty())j++;
            if(j>k){
                j--;
                reverse(s.begin()+i-2,s.begin()+i);
                ans.push_back(make_pair(i-1,i));
            }
        }
        if(j<k){
            for(i=0;;i++){
                if(i==n){
                    j=1;
                    i=0;
                    while(!par.empty())par.pop();
                }
                if(s[i]=='(')par.push(s[i]);
                else{
                    par.pop();
                    if(par.empty()){
                         if(i==n-1)continue;
                        j++;
                    }
                    else{
                        if(par.size()==1){
                            j++;
                        }

                        reverse(s.begin()+i-1,s.begin()+i+1);
                        ans.push_back(make_pair(i,i+1));

                    }
                }
                //cout<<j<<" "<<i<<endl;
                if(j==k)break;
            }
        }
        //cout<<s<<endl;

        cout<<ans.size()<<endl;
        for(i=0;i<ans.size();i++){
            cout<<ans[i].first<<" "<<ans[i].second<<endl;
        }

    }

    return 0;
}
/*
1
10 5
((((()))))
*/


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define pii pair<ll,ll>
#define ppi pair<pii,ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    int n,t,k,i,j;
    cin>>t;
    string s,temp;
    while(t--){
        vector<pii>ans;
        cin>>n>>k;
        cin>>s;
        int o,c;
        c=o=0;
        int cnt=k,st;
        st=0;
        stack<char>par;

        for(i=0;i<n;i++){
            if(s[i]=='(')
                par.push('(');
            else if(!par.empty()){
                par.pop();
            }
            else{
                for(j=i;j<n;j++){
                    if(s[j]=='(')o++;
                    else c++;
                    if(o==c){
                        reverse(s.begin()+i,s.begin()+j+1);
                        ans.push_back(make_pair(i+1,j+1));
                        i=j;
                        break;
                    }
                }
            }
        }
        while(!par.empty()){
            par.pop();
        }
        j=0;
        for(i=0;i<n;i++){
            if(s[i]=='(')par.push(s[i]);
            else par.pop();
            if(par.empty())j++;
            if(j>k){
                j--;
                reverse(s.begin()+i-2,s.begin()+i);
                ans.push_back(make_pair(i-1,i));
            }
        }
        if(j<k){
            j=1;
            for(i=0;;i++){
                if(i==n){
                    i=0;
                    while(!par.empty())par.pop();
                }
                if(s[i]=='(')par.push(s[i]);
                else{
                    par.pop();
                    if(par.empty()){
                         //if(i==n-1)continue;
                        j++;
                    }
                    else{
                        if(par.size()==1){
                            j++;
                        }

                        reverse(s.begin()+i-1,s.begin()+i+1);
                        ans.push_back(make_pair(i,i+1));

                    }
                }
                cout<<j<<" "<<i<<endl;
                if(j==k)break;
            }
        }
        cout<<s<<endl;

        cout<<ans.size()<<endl;
        for(i=0;i<ans.size();i++){
            cout<<ans[i].first<<" "<<ans[i].second<<endl;
        }

    }

    return 0;
}
/*
1
10 5
((((()))))
*/


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define pii pair<ll,ll>
#define ppi pair<pii,ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    int n,t,k,i,j;
    cin>>t;
    string s,temp;
    while(t--){
        vector<pii>ans;
        cin>>n>>k;
        cin>>s;
        int o,c;
        c=o=0;
        int cnt=k,st;
        st=0;
        stack<char>par;

        for(i=0;i<n;i++){
            if(s[i]=='(')
                par.push('(');
            else if(!par.empty()){
                par.pop();
            }
            else{
                for(j=i;j<n;j++){
                    if(s[j]=='(')o++;
                    else c++;
                    if(o==c){
                        reverse(s.begin()+i,s.begin()+j+1);
                        ans.push_back(make_pair(i+1,j+1));
                        i=j;
                        break;
                    }
                }
            }
        }
        while(!par.empty()){
            par.pop();
        }
        j=0;
        for(i=0;i<n;i++){
            if(s[i]=='(')par.push(s[i]);
            else par.pop();
            if(par.empty())j++;
            if(j>k){
                j--;
                reverse(s.begin()+i-2,s.begin()+i);
                ans.push_back(make_pair(i-1,i));
            }
        }
        if(j<k){
            j=1;
            for(i=0;i<n;i++){
                if(s[i]=='(')par.push(s[i]);
                else{
                    par.pop();
                    if(par.empty()){
                        j++;
                    }
                    else{
                        if(par.size()==1)
                            j++;
                        reverse(s.begin()+i-1,s.begin()+i+1);
                        ans.push_back(make_pair(i,i+1));
                    }
                }
                if(j==k)break;
            }
        }
        cout<<ans.size()<<endl;
        for(i=0;i<ans.size();i++){
            cout<<ans[i].first<<" "<<ans[i].second<<endl;
        }
        ans.clear();
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define pii pair<ll,ll>
#define ppi pair<pii,ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    int n,t,k,i,j;
    cin>>t;
    string s,temp;
    while(t--){
        vector<pii>ans;
        cin>>n>>k;
        cin>>s;
        int o,c;
        c=o=0;
        int cnt=k,st;
        st=0;
        stack<char>par;

        for(i=0;i<n;i++){
            if(s[i]=='(')
                par.push('(');
            else if(!par.empty()){
                par.pop();
            }
            else{
                for(j=i;j<n;j++){
                    if(s[j]=='(')o++;
                    else c++;
                    if(o==c){
                        reverse(s.begin()+i,s.begin()+j+1);
                        ans.push_back(make_pair(i+1,j+1));
                        i=j;
                        break;
                    }
                }
            }
        }
        while(!par.empty()){
            par.pop();
        }
        j=1;
        int l=n/2;
        for(i=0;;i++){
            if(i==n){
                j=1;
                i=0;
                while(!par.empty())par.pop();
            }
            if(s[i]=='(')par.push(s[i]);
            else{
                par.pop();
                if(par.empty()){
                     if(i==n-1)continue;
                    j++;
                }
                else{
                    if(par.size()==1){
                        j++;
                    }
                    reverse(s.begin()+i-1,s.begin()+i+1);
                    ans.push_back(make_pair(i,i+1));

                }
            }
            //cout<<j<<" "<<i<<endl;
            if(j==l)break;
        }
        j=0;

        while(!par.empty()){
            par.pop();
        }
        for(i=0;i<n;i++){
            if(s[i]=='(')par.push(s[i]);
            else par.pop();
            if(par.empty())j++;
            if(j>k){
                j--;
                reverse(s.begin()+i-2,s.begin()+i);
                ans.push_back(make_pair(i-1,i));
            }
        }

        cout<<ans.size()<<endl;
        for(i=0;i<ans.size();i++){
            cout<<ans[i].first<<" "<<ans[i].second<<endl;
        }

    }

    return 0;
}
/*
1
10 5
((((()))))
*/


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define pii pair<ll,ll>
#define ppi pair<pii,ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    int n,t,k,i,j;
    cin>>t;
    string s,temp;
    while(t--){
        vector<pii>ans;
        cin>>n>>k;
        cin>>s;
        int o,c;
        c=o=0;
        int cnt=k,st;
        st=0;
        stack<char>par;

        for(i=0;i<n;i++){
            if(s[i]=='(')
                par.push('(');
            else if(!par.empty()){
                par.pop();
            }
            else{
                for(j=i;j<n;j++){
                    if(s[j]=='(')o++;
                    else c++;
                    if(o==c){
                        reverse(s.begin()+i,s.begin()+j+1);
                        ans.push_back(make_pair(i+1,j+1));
                        i=j;
                        break;
                    }
                }
            }
        }
        while(!par.empty()){
            par.pop();
        }
        j=0;
       // cout<<s<<endl;

        for(i=0;i<n;i++){
            if(s[i]=='(')par.push(s[i]);
            else par.pop();
            if(par.empty())j++;
            if(j>k){
                j--;
                reverse(s.begin()+i-2,s.begin()+i);
                ans.push_back(make_pair(i-1,i));
            }
        }
        j=0;
        for(i=0;i<n;i++){
            if(s[i]=='(')par.push(s[i]);
            else par.pop();
            if(par.empty())j++;
            if(j>k){
                j--;
                reverse(s.begin()+i-2,s.begin()+i);
                ans.push_back(make_pair(i-1,i));
            }
        }
  //      cout<<j<<endl;
        if(j<k){
            j=1;
            for(i=0;;i++){
                if(i==n){
                    j=1;
                    i=0;
                    while(!par.empty())par.pop();
                }
                if(s[i]=='(')par.push(s[i]);
                else{
                    par.pop();
                    if(par.empty()){
                         if(i==n-1)continue;
                        j++;
                    }
                    else{
                        if(par.size()==1){
                            j++;
                        }

                        reverse(s.begin()+i-1,s.begin()+i+1);
                        ans.push_back(make_pair(i,i+1));

                    }
                }
                //cout<<j<<" "<<i<<endl;
                if(j==k)break;
            }
        }
        //cout<<s<<endl;

        cout<<ans.size()<<endl;
        for(i=0;i<ans.size();i++){
            cout<<ans[i].first<<" "<<ans[i].second<<endl;
        }

    }

    return 0;
}
/*
1
10 5
((((()))))
*/