N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) sumAB,sumB2,sumAB2 = 0,0,0 for a,b in zip(A,B): sumAB += a*b sumAB2 += ((a**2)*(b**2)) sumB2 += b**2 X = sumAB/sumB2 FX = 0 for a,b in zip(A,B): FX += b*abs(X-a) if X.is_integer(): X = int(X) if FX.is_integer(): FX = int(FX) print(X,FX)