n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) def f(x): res = 0 for i in range(n): res += b[i] * abs(x - a[i]) return res l = -1e18 r = 1e18 for i in range(1000): llr = (l + l + r) / 3 lrr = (l + r + r) / 3 vl = f(llr) vr = f(lrr) if vl > vr: l = llr else: r = lrr print(round(l), round(f(l)))