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