import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) s = sum(B) cnt = [0]*(2*10**6+10) for Ai, Bi in zip(A, B): cnt[Ai+10**6] += Bi acc = 0 for i in range(2*10**6+10): acc += cnt[i] if acc>=s//2+1: x = i-10**6 break fx = sum(Bi*abs(x-Ai) for Ai, Bi in zip(A, B)) print(x, fx)