N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) def f(x): tot = 0 for i in range(N): tot += B[i]*abs(x-A[i]) return tot low = -10**6-10 high = 10**6+10 while high-low>2: left = (2*low+high)//3 right = (low+2*high)//3 if f(right)>f(left): high = right else: low = left r = f((low+2*high)//3) l = f((2*low+high)//3) if r>l: print((2*low+high)//3,l) else: print((low+2*high)//3,r)