from collections import defaultdict import heapq n = int(input()) x = list(map(int,input().split())) a = list(map(int,input().split())) d = defaultdict(int) hq = [] for i in range(n): d[x[i]] = a[i] heapq.heappush(hq,[-x[i]-a[i] , i]) ans = [0] * n while hq: _,idx = heapq.heappop(hq) ans[idx] = max(a[idx] , d[x[idx] + a[idx]] + a[idx] , d[x[idx] - a[idx]] - a[idx]) d[x[idx]] = ans[idx] print(*ans,sep="\n")