import sys def S(): return sys.stdin.readline().rstrip() def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LS(): return list(sys.stdin.readline().rstrip().split()) n = I() a = LI() b = LI() L = [] sb = sum(b) for i in range(n): L.append([a[i], b[i]]) L.sort() tmp = 0 ans = n for i in range(n): tmp += b[i] if tmp >= (sb+1)//2: ans = i break fx = 0 for i in range(n): fx += b[i]*abs(a[i]-a[ans]) print(a[ans], fx)