using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var x = NList; var a = NList; var set = new HashSet(x); for (var i = 0; i < n; ++i) { set.Add(x[i] - a[i]); set.Add(x[i] + a[i]); } var list = new List(set); list.Sort(); var dic = new Dictionary(); for (var i = 0; i < list.Count; ++i) dic[list[i]] = i; var tree = new List[list.Count]; for (var i = 0; i < tree.Length; ++i) tree[i] = new List(); var refs = new int[list.Count]; for (var i = 0; i < n; ++i) { tree[dic[x[i] - a[i]]].Add(dic[x[i]]); tree[dic[x[i] + a[i]]].Add(dic[x[i]]); refs[dic[x[i]]] += 2; } var q = new Queue(); for (var i = 0; i < list.Count; ++i) if (refs[i] == 0) q.Enqueue(i); var max = list.ToList(); while (q.Count > 0) { var cur = q.Dequeue(); for (var i = tree[cur].Count - 1; i >= 0; --i) { max[tree[cur][i]] = Math.Max(max[tree[cur][i]], max[cur]); --refs[tree[cur][i]]; if (refs[tree[cur][i]] == 0) q.Enqueue(tree[cur][i]); tree[cur].RemoveAt(i); } } var uf = new UnionFindTree(list.Count); for (var i = 0; i < list.Count; ++i) foreach (var next in tree[i]) uf.Unite(i, next); for (var i = 0; i < list.Count; ++i) max[uf.GetRoot(i)] = Math.Max(max[uf.GetRoot(i)], max[i]); WriteLine(string.Join("\n" , x.Select(xi => max[uf.GetRoot(dic[xi])] - xi))); } class UnionFindTree { int[] roots; public UnionFindTree(int size) { roots = new int[size]; for (var i = 0; i < size; ++i) roots[i] = -1; } public int GetRoot(int a) { if (roots[a] < 0) return a; return roots[a] = GetRoot(roots[a]); } public bool IsSameTree(int a, int b) { return GetRoot(a) == GetRoot(b); } public bool Unite(int a, int b) { var x = GetRoot(a); var y = GetRoot(b); if (x == y) return false; if (-roots[x] < -roots[y]) { var tmp = x; x = y; y = tmp; } roots[x] += roots[y]; roots[y] = x; return true; } public int GetSize(int a) { return -roots[GetRoot(a)]; } } }