from itertools import product def mix(S, lr, rr): lm = lr.keys() rm = rr.keys() wr = {} for l, r in product(lm, rm): p = S[l] / (S[l] + S[r]) wr[l, r] = p wr[r, l] = 1 - p result = {} for l in lm: result[l] = lr[l] * sum(wr[l, r] * rr[r] for r in rm) for r in rm: result[r] = rr[r] * sum(wr[r, l] * lr[l] for l in lm) return result def solve(M, S): print(S) range_len_s = list(range(len(S))) R = [{i: 1.0} for i in range_len_s] print(R) for i in range(M): step = 2 ** i print("_______________") print(i, step) m = list(range(0, len(S), step)) for j in range(0, len(m), 2): lr = R[m[j]] rr = R[m[j + 1]] print(j, m[j], m[j + 1], lr, rr) R[m[j]] = mix(S, lr, rr) print(R) return R[0][0] def main(): M = int(input()) n = 2 ** M S = [int(input()) ** 2 for i in range(n)] print(solve(M, S)) if __name__ == '__main__': main()