#!/bin/python3 from collections import defaultdict import sys def maximumPeople(n, p, x, y, r): # p = populations; x = locations of towns; y = location of clouds; r = range of clouds # Return the maximum number of people that will be in a sunny town after removing exactly one cloud. towns = defaultdict(tuple) i = 0 for loc in x: towns[loc] = (p[i], []) i += 1 clouds = list(zip(y, r)) for cloud, r in clouds: try: towns[cloud][1] += [cloud] except: pass for i in range(r): try: towns[cloud-i][1] += [cloud] except: pass try: towns[cloud+1][1] += [cloud] except: pass totalSunny = 0 for town, pair in towns.items(): try: pop, cloud = pair if len(cloud) == 0: totalSunny += pop except: pass i = 0 for cloud, r in clouds: temp = totalSunny try: temp += towns[cloud][0] except: pass for i in range(1,r+1): try: temp += towns[cloud-i][0] except: pass try: temp += towns[cloud+i][0] except: pass totalSunny = max(temp, totalSunny) return totalSunny 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(n, p, x, y, r) print(result)