#!/bin/python3 import sys def maximumPeople(p, x, y, r): #print (p) #print (x) #print (y) #print (r) rng = [] #print(y[0]) clouds = len(y) towns = len(x) #print(clouds) for i in range(0,clouds): hello = list(range(y[i]-r[i],y[i]+r[i]+1)) # print(hello) rng.append(hello) #print(rng) rem = [0] k=0 for i in range(0,clouds): rgcloud = rng[i] for j in range(0,towns): loctown = x[j] if(loctown in rgcloud): rem[i]+=p[j] nottt = 0 if(sum(p)>sum(rem)): nottt = sum(p)-sum(rem) #print(rem) m = max(rem) fin = [] fin = [i for i, j in enumerate(rem) if j == m] #print(fin[0]) ans =rem[fin[0]]+nottt #print(ans) return ans # Return the maximum number of people that will be in a sunny town after removing exactly one cloud. if __name__ == "__main__": n = int(input().strip())#num towns p = list(map(int, input().strip().split(' ')))#population list x = list(map(int, input().strip().split(' ')))#location list m = int(input().strip())#num clouds y = list(map(int, input().strip().split(' ')))#location list r = list(map(int, input().strip().split(' ')))#range list result = maximumPeople(p, x, y, r) print(result)