#!/bin/python3 import sys def maximumPeople(p, x, clouds, r): # Return the maximum number of people that will be in a sunny town after removing exactly one cloud. count = 0 total_population = 0 most_population = 0 marked = [] for i in p: marked.append(1) cloud_num = 0 for cloud in clouds: cloud_size = r[cloud_num] if cloud - cloud_size in x: if p[x.index(cloud-cloud_size)] > most_population: most_population = p[x.index(cloud-cloud_size)] marked[cloud_num] = 0 elif cloud in x: if p[x.index(cloud-cloud_size)] > most_population: most_population = p[x.index(cloud)] marked[cloud_num] = 0 elif cloud + cloud_size in x: if p[x.index(cloud+cloud_size)] > most_population: most_population = p[x.index(cloud+cloud_size)] marked[cloud_num] = 0 check = 0 for i in marked: if i != 0: total_population += p[check] check += 1 return total_population + most_population 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)