N = int(input()) *A, = map(int, input().split()) *X, = map(int, input().split()) *Y, = map(int, input().split()) N0 = 2**(N-1).bit_length() A = A + [10**6] * (N0 - N) data = [None]*(2*N0+1) # Li Chao Tree def f(line, x): p, q = line return p*x + q def _add_line(line, a, b, k, l, r): if r <= a or b <= l: return m = (l + r) // 2 if not (a <= l and r <= b): _add_line(line, a, b, 2*k+1, l, m) _add_line(line, a, b, 2*k+2, m, r) return if data[k] is None: data[k] = line return lx = A[l] mx = A[m] rx = A[r-1] left = (f(line, lx) < f(data[k], lx)) mid = (f(line, mx) < f(data[k], mx)) right = (f(line, rx) < f(data[k], rx)) if left and right: data[k] = line return if not left and not right: return if mid: data[k], line = line, data[k] if left != mid: _add_line(line, 2*k+1, l, m) else: _add_line(line, 2*k+2, m, r) def add_line(line, a, b): return _add_line(line, a, b, 0, 0, N0) def query(k, x): def gen(k, x): k += N0-1 while k >= 0: if data[k]: yield f(data[k], x) k = (k - 1) // 2 return min(gen(k, x)) v = 0 j = 0 for i in range(N): x = X[i]; a = A[i]; y = Y[i] while A[j+1] < x: j += 1 add_line((-1, x+y+v), 0, j) add_line((1, -x+y+v), j, N0) v = query(i, a) print(v)