n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) ans1, ans2 = None, 10**15 for z in a: tmp = 0 for x, y in zip(a, b): tmp += y * abs(z - x) if tmp < ans2: ans1, ans2 = z, tmp print(ans1, ans2)