# coding: utf-8 # Your code here! N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) C=[[A[i],B[i]] for i in range(N)] if N==1: print(0,0) exit() sumB=sum(B) C.sort(key=lambda x:x[0]) temp=0 for index in range(N-1): temp+=B[index] if temp>=sumB/2: break X=(C[index][0]+C[index+1][0])/2 if temp==sumB/2 else C[index][0] ans=0 for a,b in C: ans+=abs(X-a)*b print(X,int(ans))