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 = -1e9 r = 1e9 for i in range(100): 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)))