#!/bin/python3 import sys def maximumPeople(p, x, y, r, m): # Return the maximum number of people that will be in a sunny town after removing exactly one cloud. cities_not_covered = x cloud_effect = {} pops = {} for i in range(len(p)): pops[x[i]]=p[i] #print(pops) for i in range(m): for j in range(y[i] - r[i], y[i] + r[i] + 1): if j>=0 and j in pops: if j in cities_not_covered: cities_not_covered.remove(j) if i in cloud_effect: cloud_effect[i] += pops[j] else: cloud_effect[i] = pops[j] max_affected = 0 #print(cities_not_covered) for k,v in cloud_effect.items(): max_affected = max(max_affected, cloud_effect[k]) for city in cities_not_covered: max_affected+=pops[city] return max_affected 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, m) print(result)