def ternary_search(f, lo, hi) -> float: l = lo r = hi for _ in range(100): c1 = (l * 2 + r) / 3 c2 = (l + r * 2) / 3 if f(c1) > f(c2): l = c1 else: r = c2 return l N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) def f(x): res = 0 for a, b in zip(A, B): res += b * abs(x - a) return res lo = min(A) hi = max(A) x = int(ternary_search(f, lo, hi)) x_ans = x v_ans = f(x_ans) for i in [x-2, x-1, x, x+1, x+2]: r = f(i) if v_ans > r: x_ans = i v_ans = r print(x_ans, v_ans)