def Ternary_Search(L,R,f,Integer=True,arg=False,ep=1/(1<<20),Times=50):
    
    if Integer:
        while (R-L)>3:
            a=(2*L+R)//3
            b=(L+2*R)//3
            p=f(a);q=f(b)
            if p<=q:
                R=b
            else:
                L=a

        a=(2*L+R)//3
        b=(L+2*R)//3
    else:
        while (R-L)>=ep and Times:
            Times-=1
            a=(2*L+R)/3
            b=(L+2*R)/3

            p=f(a);q=f(b)
            if p<=q:
                R=b
            else:
                L=a

        a=(2*L+R)/3
        b=(L+2*R)/3

    if arg:
        y=float("inf")
        argx=-1
        for x in [L,a,b,R]:
            p=f(x)
            if y>p:
                y=p
                argx=x
        return y,argx
    else:
        return min(f(L),f(a),f(b),f(R))
#================================================
def f(x):
    X=0
    for a,b in zip(A,B):
        X+=b*abs(x-a)
    return X
#================================================
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

y,x=Ternary_Search(min(A),max(A),f,True,True)
print(x,y)