#!/bin/python 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. location_to_pop = {x[i]:p[i] for i in xrange(n)} best_cloud_pop = 0 #best_cloud_cities = [] for i in xrange(m): cloud_pop = 0 #cloud_cities = [] for c in xrange(y[i] - r[i], y[i] + r[i] + 1): try: cloud_pop += location_to_pop[c] #cloud_cities.append(c) del location_to_pop[c] except: pass if cloud_pop > best_cloud_pop: best_cloud_pop = cloud_pop #best_cloud_cities = cloud_cities[:] total = best_cloud_pop for pop in location_to_pop.values(): total += pop return total if __name__ == "__main__": n = int(raw_input().strip()) p = map(long, raw_input().strip().split(' ')) x = map(long, raw_input().strip().split(' ')) m = int(raw_input().strip()) y = map(long, raw_input().strip().split(' ')) r = map(long, raw_input().strip().split(' ')) result = maximumPeople(p, x, y, r) print result