from itertools import accumulate from bisect import bisect_left N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) BA=list(accumulate(B)) num=(BA[-1]+1)//2 idx=bisect_left(BA,num) ans=0 for i in range(N): ans+=B[i]*abs(A[idx]-A[i]) print(A[idx],ans)