#include #include #include using namespace std; typedef long double ld; int a[1010]; ld r[1010],dp[510][510] = {}; int main(){ cout.precision(20); int i,j,k,n; cin >> n; for(i=0;i> a[i]; for(i=0;i> r[i]; ld ans = 0; for(int val = 1;val<=1000;val++){ for(i=0;i<=n;i++){ for(j=0;j<=n + 1;j++) dp[i][j] = 0; } dp[0][0] = 1; for(i=1;i<=n;i++){ for(j=0;j<=i;j++){ if(a[i - 1]0) dp[i][j] += dp[i - 1][j - 1]/2; }else{ if(j>0) dp[i][j] = dp[i - 1][j]/2 + dp[i - 1][j + 1]/2; else dp[i][j] = dp[i - 1][j] + dp[i - 1][j + 1]/2; } } } for(i=1;i<=n;i++){ if(a[i - 1]>=val) ans += r[i - 1]*dp[i - 1][0]/2; } } cout << ans << endl; }