n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) ans=[0]*(3000000) sumb=sum(b) def f(x): global n res=0 for i in range(n): res+=b[i]*abs(x-a[i]) return res for i in range(n): ans[a[i]]+=b[i] a.sort() num=0 for x in a: num+=ans[x] if num*2>=sumb: print(x,f(x)) exit()