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() cum = [None] * (n + 1) cum[0] = 0 for i in range(n): cum[i + 1] = cum[i] + P[i][1] mindiff = 10 ** 7 mp = None for i in range(n): d = abs(cum[i] - (cum[n] - cum[i + 1])) if mindiff > d: mindiff = d mp = P[i][0] if i >= n - 1: continue d = abs(cum[i + 1] - (cum[n] - cum[i + 1])) if mindiff > d: mindiff = d mp = (P[i][0] + P[i + 1][0]) * 0.5 def f(x): res = 0 for i in range(n): res += B[i] * abs(x - A[i]) return res # lo, hi, minima = min(A) - 1, max(A) + 1, None # for i in range(300): # x = lo + (hi - lo) / 3.0 # y = lo + (hi - lo) * 2.0 / 3.0 # fx, fy = f(x), f(y) # if fx > fy: # lo = x # minima = fy # else: # hi = y # minima = fx return "{:.9f}".format(mp), int(f(mp) + 0.5) print(*solve())