import bisect n = int(input()) X = list(map(int, input().split())) A = list(map(int, input().split())) right = [0] * n left = [0] * n # Calculate right array from the end to the beginning for i in reversed(range(n)): pos = X[i] + A[i] j = bisect.bisect_left(X, pos) if j < n and X[j] == pos: right[i] = A[i] + max(right[j], left[j]) else: right[i] = A[i] # Calculate left array from the beginning to the end for i in range(n): pos = X[i] - A[i] j = bisect.bisect_left(X, pos) if j < n and X[j] == pos: left[i] = -A[i] + max(right[j], left[j]) else: left[i] = -A[i] # Determine the maximum positive distance for each person for i in range(n): max_dist = max(right[i], left[i]) print(max(max_dist, 0))