import sys;input=sys.stdin.readline N, = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = [0]*(N+1) D = [0]*(N+1) E = [0]*(N+1) F = [0]*(N+1) for i in range(N): C[i+1] += C[i] + B[i] D[i+1] += D[i] - A[i]*B[i] for i in range(N-1, -1, -1): E[i] += E[i+1] + B[i] F[i] += F[i+1] - A[i]*B[i] m = 10**18 for i in range(N): r = (-E[i+1]+C[i])*A[i]+(-F[i+1]+D[i]) if r < m: m = r mx = A[i] print(mx, m)