import sys sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inl = lambda: [int(x) for x in sys.stdin.readline().split()] ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) def solve(): n = ini() A = inl() B = inl() P = [] for i in range(n): P.append((A[i], B[i])) P.sort() if n == 1: return A[0], 0 cum = [None] * (n + 1) cum[0] = 0 for i in range(n): cum[i + 1] = cum[i] + P[i][1] mindiff = 10 ** 8 mp = 0 for i in range(n): d = abs(cum[n] - 2 * cum[i]) if mindiff > d: mindiff = d mp = i def f(x): res = 0 for i in range(n): res += B[i] * abs(x - A[i]) return res return P[mp][0], int(f(P[mp][0]) + 0.5) print(*solve())