N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) if N == 1: print(A[0]) else: X = sorted(A)[(N - 1) // 2] Y = sorted(A)[(N - 1) // 2 + 1] S = sum([b * abs(X - a) for a, b in zip(A, B)]) T = sum([b * abs(Y - a) for a, b in zip(A, B)]) if S > T: print(Y, T) else: print(X, S)