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 = ternary_search(f, lo, hi) x = int(x + 0.5) print(x, f(x))