#!/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. cloud=[] for i in range(0,len(y)): cloud.append(list(range(y[i]-r[i],y[i]+r[i]+1))) towns=[] for each in cloud: s=[p[x.index(j)] for j in each if j in x] su=sum(s) towns.append(su) max_ppl=max(towns) cloud_covered=[] for each in cloud: for j in each: cloud_covered.append(j) max_ppl+=sum([p[x.index(j)] for j in x if j not in cloud_covered]) return(max_ppl) 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)