def f(x):
    S=0
    for k in range(N):
        S+=B[k]*abs(x-A[k])
    return S

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
B_sum=sum(B)

L=[0]*N
for k in range(N):
    L[k]=(A[k],B[k])

L.sort(key=lambda x:x[0])

Med=(B_sum+1)//2
Count=0

for (X,Y) in L:
    Count+=Y
    if Med<=Count:
        break

print(X,f(X))