#!/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. max_pop = 0 for cloud_id in range(len(y)): pop = 0 cloud_beg = y[cloud_id] - r[cloud_id] cloud_end = y[cloud_id] + r[cloud_id] for city_id in range(len(x)): if x[city_id] >= cloud_beg or x[city_id] <= cloud_end: pop += p[city_id] if pop > max_pop: max_pop = pop happy_pop = 0 for city_id in range(len(x)): check = True for cloud_id in range(len(y)): cloud_beg = y[cloud_id] - r[cloud_id] cloud_end = y[cloud_id] + r[cloud_id] if x[city_id] >= cloud_beg or x[city_id] <= cloud_end: check = False if check: happy_pop += p[city_id] return max_pop + happy_pop 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)