#!/bin/python3 import sys def maximumPeople(p, x, y, r): count = 0 if(len(y) == 1): for i in range(0,len(p)): count+=p[i] return count locs = [t for _, t in sorted(zip(p,x) ,reverse = True)] cover = [t for _,t in sorted(zip(r,y) ,reverse = True)] r = sorted(r, reverse=True) p = sorted(p, reverse = True) # print('p',p) # print('locs',locs) # print('r',r) # print('c',cover) count = -99999 markc = [0 for i in range(0,len(p))] for i in range(0,len(cover)): temp = 0 for j in range(0,len(locs)): if(cover[i] - r[i] <= locs[j] and locs[j] <= cover[i] + r[i]): temp += p[j] markc[j]+=1 count = max(temp, count) for i in range(0,len(markc)): if(markc[i] == 0): count+=p[i] return count 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)