import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N = int(input()) A = li() B = li() stack = [(A[0],B[0])] for i in range(1,N): a,b = A[i],B[i] while stack: pa,pb = stack[-1] if pa*b >= a*pb: stack.pop() a,b = pa+a,pb+b else: break stack.append((a,b)) res = 0 for a,b in stack: if a <= b: res += a + b else: res += 2 * (a*b)**.5 print(res)