#!/bin/python3 import sys def maximumPeople(p, x, y, r): # Return the maximum number of people that will be in a sunny town after removing exactly one cloud. popc=[] indsunpop=[] for i in range(len(y)): sumpop=0 for k in range(len(x)): if y[i]-r[i]<=x[k]<=y[i]+r[i]: sumpop+=p[k] if k in indsunpop: indsunpop.remove(k) else: if not(k in indsunpop): indsunpop+=[k] popc+=[sumpop] sunpop=sum(list(map(lambda x:p[x],indsunpop))) return sunpop+max(popc) if __name__ == "__main__": n = int(input().strip()) p = list(map(int, input().strip().split(' '))) x = list(map(int, input().strip().split(' '))) m = int(input().strip()) y = list(map(int, input().strip().split(' '))) r = list(map(int, input().strip().split(' '))) result = maximumPeople(p, x, y, r) print(result)