#!/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. sun=[1]*len(p) for j in range(0,len(y)): max=0 temp=0 ind=0 for i in x: if(i>=y[j]-r[j] and i<=y[j]-r[j]): temp=temp+p[x.index(i)] sun[x.index(i)]=0 if(temp>max): max=temp ind=j pop=0 for i in range(len(p)): pop=pop+(p[i]*sun[i]) pop=pop+max return pop 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)