#!/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. pos_tc = [] cou=0 pol = -1 for i in range(0,len(x)): for j in range(0,len(y)): pos_c = y[j]+r[j] if x[i]<= (pos_c) and x[i]>=pos_c: if pol < p[i]: pol = p[i] else: cou+=p[i] return pol+cou 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)