def scc(N, G, RG): order = [] used = [0]*N group = [None]*N def dfs(s): used[s] = 1 for t in G[s]: if not used[t]: dfs(t) order.append(s) def rdfs(s, col): group[s] = col used[s] = 1 for t in RG[s]: if not used[t]: rdfs(t, col) for i in range(N): if not used[i]: dfs(i) used = [0]*N label = 0 for s in reversed(order): if not used[s]: rdfs(s, label) label += 1 return label, group # 縮約後のグラフを構築 def construct(N, G, label, group): G0 = [set() for i in range(label)] GP = [[] for i in range(label)] for v in range(N): lbs = group[v] for w in G[v]: lbt = group[w] if lbs == lbt: continue G0[lbs].add(lbt) GP[lbs].append(v) return G0, GP n=int(input()) x=list(map(int,input().split())) a=list(map(int,input().split())) G=[[] for i in range(n)] RG=[[] for i in range(n)] id={} for i in range(n): id[x[i]]=i for i in range(n): xi,ai=x[i],a[i] if xi-ai in id: j=id[xi-ai] G[j].append(i) RG[i].append(j) if xi+ai in id: j=id[xi+ai] G[j].append(i) RG[i].append(j) label,group=scc(n,G,RG) G0,GP=construct(n, G, label, group) mx=[a[i]+x[i] for i in range(n)] mx2=[0]*label for i in range(label): tmp=mx2[i] for j in GP[i]: tmp=max(tmp,mx[j]) for j in GP[i]: mx[j]=tmp for to in G0[i]: mx2[to]=max(tmp,mx2[to]) for i in range(n): print(mx[i]-x[i])