#!/bin/python3 import sys def maximumPeople(n, p, x, m, y, r): y1=[j for i in range(m) for j in range(y[i]-r[i],y[i]+r[i]+1)] y2=list(set(y1)) x1=[] co=0 for j in range(n): if x[j] in y2: x1.append(p[j]) else: co+=p[j] return (co+max(x1)) 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(n, p, x, m, y, r) print(result)