from functools import lru_cache n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) @lru_cache(maxsize=None) def F(x): return sum(b * abs(x - a) for a, b in zip(A, B)) D = n.bit_length() i = 0 C = sorted(A) for d in reversed(range(D)): shift = 1 << d if F(i) > F(i+d): i += shift print(i, F(i))