import sys readline = sys.stdin.readline n = int(readline()) *A, = map(int,readline().split()) *B, = map(int,readline().split()) q = [] ans = 0.0 for a,b in zip(A,B): while a <= b: if not q: break else: x,y = q.pop() a += x b += y if a <= b: ans += a+b else: q.append((a,b)) x = y = 0.0 for a,b in q: if x*b >= a*y: x += a y += b else: ans += 2*((x*y)**0.5) x = a y = b ans += 2*((x*y)**0.5) print(ans)