N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) X = sorted(A)[(N - 1) // 2] print(X, sum([b * abs(X - a) for a, b in zip(A, B)]))