#!/bin/python3 import sys def item(x): return x[0] def maximumPeople(pop, loc, poc, r,n,m): # Return the maximum number of people that will be in a sunny town after removing exactly one cloud. total=sum(pop) rainy=[] region=[] cloud=[] for i in range(len(pop)): region.append((loc[i],pop[i])) for i in range (len(poc)): cloud.append((poc[i]-r[i],poc[i]+r[i])) region.sort(key=item) cloud.sort(key=item) i=0 j=0 while(j=l and i[0]<=h: val+=i[1] elif i[0]>h: break rainy.append(val) j+=1 return (total-sum(rainy)+max(rainy)) if __name__ == "__main__": n = int(input().strip()) pop = list(map(int, input().strip().split(' '))) loc = list(map(int, input().strip().split(' '))) m = int(input().strip()) poc = list(map(int, input().strip().split(' '))) r = list(map(int, input().strip().split(' '))) result = maximumPeople(pop, loc, poc, r,n,m) print(result)