#!/bin/python3 import sys def maximumPeople(p, x, y, r): max1=0 bl=[] for i in range(0,len(p)): bl.append(False) # Return the maximum number of people that will be in a sunny town after removing exactly one cloud. for i in range(0,len(y)): ran=r[i] for j in range(0,len(x)): if x[j]>=y[i]-ran and x[j]<=y[i]+ran: bl[j]=True if p[j]>max1: max1=p[j] for i in range(0,len(bl)): if bl[i]==False: max1=max1+p[i] return max1 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)