n = int(input()) ab = [] for a, b in zip(map(int, input().split()), map(int, input().split())): ab.append((a, b)) ab.sort() x = ab[n // 2][0] ans = 0 for a, b in ab: ans += b * abs(x - a) print(x, ans)