#include #include #include #include #include #include #include #include #include #include #define mkp make_pair #define mkt make_tuple #define rep(i,n) for(int i = 0; i < (n); ++i) #define all(v) v.begin(),v.end() using namespace std; typedef long long ll; const ll MOD=1e9+7; template void chmin(T &a,const T &b){if(a>b) a=b;} template void chmax(T &a,const T &b){if(a A; typedef tuple TP; map mp; double solve(int c,int state,int win){ TP tmp=mkt(c,state,win); if(mp.count(tmp)) return mp[tmp]; if(state==0){ int s=0,t=0; rep(i,N){ if(win&(1<t)||(c==1&&s<=t)) return mp[tmp]=1; else return mp[tmp]=0; } double res=0; for(int a=0;a>N; A.resize(N); rep(i,N) cin>>A[i]; double ans=solve(0,(1<